Advertisement

C++ problem: input

Started by October 26, 2000 10:11 PM
0 comments, last by ryanc 24 years, 2 months ago
        
cout<<"Press a key...";
cout.flush();
while(!kbhit());
cout<<"Type an integer";
cin>>variable;             
when I use this code above, the kbhit() waits for a key press. Once you press something, it ask for an integer, but whatever I typed before is already inputed. What statement can I insert in that will flush the stream or something and will wait for an integer when prompted? Any tips would be appreciated (FYI:I'm a novice in C++) RyanC --------------------------- Games are only as good as you make them... Edited by - ryanc on 10/26/00 10:30:01 PM
---------------------------<code>!ERR(0493): An error occured in cerebral cortex at location 0x00f230f8!: Buffer Overflow
Just read the input into an char variable first. Or alternately in C style functions use getch().

This topic is closed to new replies.

Advertisement