DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    24

    Question cin.getline help

    I’ve declared:
    char charInput[9]
    int intMonth, intDay, intYear
    The user will input 3 integers (month day year: 7 10 81)
    To Capture the input from the buffer, I have:
    cin.getline(charInput, 9)
    My question is, can the three integers entered be assigned to the corresponding variable names?

    Thanks.

  2. #2
    Join Date
    Nov 2003
    Posts
    4,118
    it depends on a crucial fatcor: does the string have blanks that separate between the numbers? If so, you can read from the string a word (a token) using the overloaded >> operator and teh stringstream objects. I think that it would be simpler for you to read the values as three strings, though.
    Danny Kalev

  3. #3
    Join Date
    Feb 2004
    Posts
    24

    Smile

    Danny, thanks for your response. I will go with the advise of three strings.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links