-
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.
-
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
-
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
Forum Rules
|
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
|
Bookmarks