I am a beginner in c++ , I need to create an application to print some thing after 10 second or after pressing a key , I tried this code but it isn’t working(after pressing a key it will print “a” lot of a instead of one “a”)
int i;
while(1)
{
i=1;
while(!kbhit()||i<1000)
{
Sleep(10);
i++;
}
cout<<"a";
}//while1
Can you suggest me any better way?
Thanks
The problem is you don’t take the first key which was pressed out of the buffer…