Write a program to constantly refresh the output 123456789, how to press enter to stop this infinite loop? (refresh type is similar to the for (;; ) {printf (" 123456789 "); })
CodePudding user response:
# include & lt; Windows. H> Int main () { while (! GetAsyncKeyState (13))//the corresponding key yourself for ASCII { Printf (" 123456789 \ n "); Sleep (50); }
return 0; }
CodePudding user response:
Can use multithreading, semaphore to implement;
The main thread receives input set a variable, the child thread print (infinite loop) and determine a variable;