Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 1st, 2005, 10:41 PM   #1
Rixx
Newbie
 
Join Date: Jun 2005
Location: Toronto
Posts: 9
Rep Power: 0 Rixx is on a distinguished road
Send a message via ICQ to Rixx Send a message via AIM to Rixx Send a message via MSN to Rixx Send a message via Yahoo to Rixx
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.
Rixx is offline   Reply With Quote
Old Jun 1st, 2005, 10:50 PM   #2
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 598
Rep Power: 4 Ancient Dragon is on a distinguished road
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()
Ancient Dragon is offline   Reply With Quote
Old Jun 1st, 2005, 11:09 PM   #3
Rixx
Newbie
 
Join Date: Jun 2005
Location: Toronto
Posts: 9
Rep Power: 0 Rixx is on a distinguished road
Send a message via ICQ to Rixx Send a message via AIM to Rixx Send a message via MSN to Rixx Send a message via Yahoo to Rixx
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..
Rixx is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:29 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC