C program press any key to continue
Improve this answer. VolAnd VolAnd 6, 3 3 gold badges 19 19 silver badges 41 41 bronze badges. CacahueteFrito agree it was in the original code , so option 2 is preferable - while getchar!
But it still has a fflush stdin in the middle. Did you forget to remove it? I would put two consecutive while getchar! Then you can remove that fflush stdin in the middle.
Add a comment. Your answer why fflush stdin will not work you can find here: How to clear input buffer in C? Community Bot 1 1 1 silver badge. Deepesh Deepesh 5, 1 1 gold badge 20 20 silver badges 38 38 bronze badges. Nitin Pandey Nitin Pandey 8 8 silver badges 24 24 bronze badges. Double getchar could not always work.
Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. That does also mean, if you are on a POSIX system, you will need to set up curses correctly before you can use getch. SungMinKim Are you using Windows?
Try this:- printf "Let the Battle Begin! Rahul Tripathi Rahul Tripathi k 30 30 gold badges silver badges bronze badges. Visual Studio The program which I use to code C states that getch is undefined.. The function you are looking for is getch as others have stated. You could also set up a loop and use kbhit , but you'll eat up CPU cycles that way without Sleep from the Windows API or whatever it is called these days, not to mention you might miss a key press if you make the thread sleep too long.
You can try more system indeppended method: system "pause" ;. Nikolai Egipko Nikolai Egipko 63 6 6 bronze badges. This is literally the most system dependent function you can use, this call will only work on Windows and you should generally avoid system calls, they make your program very OS specific.
Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually.
Linked 0. Related Hot Network Questions. Using the functions in stdio. And the answer is that there is no portable solution. When you ask in comp. After all, if you wanted a system-specific solution, you'd have asked in a system-specific newsgroup, right? So you shouldn't use that solution either. After all, you want to be portable, don't you?
Press Any Key To Continue Hi, I would like to emulate at the end of a page, the line that you find on the dos window at the end of a program 'press any key to continue'. Thanks Philippe. This can only be done using system specific non-standard extensions. Regards, Paul Quote:.
0コメント