Newbie Need Help With Simple C++ Stuff
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.
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.
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.
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement