cin.getline help


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: cin.getline help

  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.

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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center