Archived

This topic is now archived and is closed to further replies.

cin.get

This topic is 5406 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

void new_game()
{
cout << "Enter Diffacalty (1-10)\n";
cout << "|: ";
cin >> diff;
cin.get();
cout << "Enter The Armies Name\n";
cout << "|: ";
getline(cin, aname, ''\n'');
cout << "Enter The Commanders Name\n";
cout << "|: ";
getline(cin, cname, ''\n'');
game_write();
}

after you put in the armies name it takes 2 spaces 2 go 2 the next one, how do you get rid of the second space?? Easy way of programming: Code, Graphics, Swearing....

Share on other sites
I assumed you''re using VC6, your problem is most likely the faulty dinkumware STL.

The fixes can be found here. There are two issues with getline that need to be repaired.

[My site|SGI STL|Bjarne FAQ|C++ FAQ Lite|MSDN|Jargon]
Ripped off from various people

Share on other sites
hmm Im trying 2 get the service pack the link is wrong and I can''t find it anywere and the string.h dosn''t have that line?
v6, any help?

Easy way of programming: Code, Graphics, Swearing....

Share on other sites
hahah flush the stream. You do it by adding
cin.ignore(80, ''\n'');

us it after EVERY cin >> or getline or cin.get statement.

Share on other sites
can someone give me the link to the patch.
or the link to the file I have 2 edit.

Easy way of programming: Code, Graphics, Swearing....

[edited by - XDarkScar on April 29, 2003 4:01:21 PM]

Share on other sites
man, well this C++ program is from 1995-98...I don''t think is has .net so I can''t fix it...

Easy way of programming: Code, Graphics, Swearing....

Share on other sites
Are you using Visual C++ 6? If so, the fixes are very clearly explained in the link I gave.

[My site|SGI STL|Bjarne FAQ|C++ FAQ Lite|MSDN|Jargon]
Ripped off from various people

Share on other sites
I am, but I can't find the file...
can you give me the link to the file?

edit: the link of the directory is not there..I did a search for string.h and found it in

C:\Program Files\Microsoft Visual Studio\VC98\Include
^
after seeing that I know I got an old version....
and it dosnt have that text..

Easy way of programming: Code, Graphics, Swearing....

[edited by - XDarkScar on April 30, 2003 2:09:28 PM]

Share on other sites
Where did you see it tell you to edit string.h? The file you are looking for is ''string'' (no extension) in that same directory.

[My site|SGI STL|Bjarne FAQ|C++ FAQ Lite|MSDN|Jargon]
Ripped off from various people