Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cin whitespace problem

Status
Not open for further replies.

Ultdrake

Programmer
Jul 15, 2002
19
0
0
CA
I want grab a string with whitespace and I try many thing... I work in vc++ console mode...

string adress;

getline(cin, adress);
or
getline(cin, adress, '\n');
or
cin >> noskipws >> adress;

the first and the second work but I have to press two time the 'Enter' key to continue and the third skip the whitespace???

Have you an idea? thanks
Fred
 
There has to be some way for the code to know when the user is done typing the address so it can load the information into a string. The normal way when using getline is to wait for the '\n'. The normal way for >> is to wait for whitespace.

What do you want to use as the indicator that the user is done typing the address?
 
Sorry, didn't see that part of your post that said you didn't want the user to hit enter twice.

This is a bug in the STL implementation used by Visual C++ 6.0. Check out this site and scroll down to the part about <string>


or look at this one


Once you apply their fix, you can use getline like you wanted to in your first try: getline(cin, adress);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top