Newbie Need Help With Simple C++ Stuff

Started by
11 comments, last by Crash 22 years, 12 months ago
try using cin.get(), and i''m not sure, but i think you need to use cin.ignore() after that as well, but i can''t remember why.
Advertisement
About use with getch() (or _getch() if you program for windows) and cout: try to put a call to cout.flush() before your getch() call, since that will flush all cout streams currently in the buffer. I don''t know why you have to do that before getch() specifically, but it works for me.

A good way to seed rand() (again, in WIN32) is to make this call: srand(GetTickCount()). This function is in the windows headers, and it measures the system time in milliseconds if I am not mistaken. This pretty much makes sure that rand()''s output will be different each time.
"Archangel, dark angellend me thy lightthrough death''s fail until we have heaven in sight"
Thanks for the help guys. I''ve got it working right now.

I tried waht grul suggested with the cout.flush() but that didn''t work so bearing in mind what Rotter and anonymous poster said I used cin.get() and cin.ignore() but this meant the user had to press enter twice, so I just put cin.get on and that works.

Thanks for the help again,
Crash

We Must Move Forwards NOT Backwards, Sideways NOT Forwards And Always Twirling Twirling Towards Success
"We Must Move Forwards NOT Backwards, Sideways NOT Forwards And Always Twirling Twirling Towards Success." - 2000"If You Keep Looking Forward Your Gonna End Up Looking Backwards At Yourself Running Sideways!" - 2001

This topic is closed to new replies.

Advertisement