![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
|
How To: Get The *Full* String Displayed <Solved>
So I'm working away at a tutorial, and I'm asking for //string name; and then outputting it later in the script but it won't accept full names for the input.
For example when it asks for your name.. cout<< "What is your name? "; cin>> name; cin.ignore() .. it fails to let me put in my first AND last name; and instead closes when I attempt it. Am I missing a key variable type, or is it something else? Thanks! ![]()
__________________
:) *~* Official Programming Wannabee & Newbie *~* :) Any help would be greatly appreciated.. Last edited by Rixx; Jun 1st, 2005 at 11:09 PM. |
|
|
|
|
|
#2 |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 598
Rep Power: 4
![]() |
that only works on words, not sentences with embedded spaces. use cin.getline()
char name[255]; cout<< "What is your name? "; cin.getline(name, sizeof(getline); cin.ignore() or this string name; cout<< "What is your name? "; getline(cin,name); cin.ignore() |
|
|
|
|
|
#3 |
|
Newbie
|
Thanks! I'm going to learn the getline versus get command here before I go to bed :-)
Cheers!
__________________
:) *~* Official Programming Wannabee & Newbie *~* :) Any help would be greatly appreciated.. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|