I am a beginner of C. I run the C program, but the window closes too fast before I can see anything. How can I pause the window?
For Linux; getchar() is all you need.
If you are on Windows, check out the following, it is exactly what you need!
kbit() function
For example, see how it works in the following program;
//any_key.c
#include
#include
int main(){
//code here
printf ("Press any key to continue . . .\n");
while (1) if (kbhit()) break;
//code here
return 0;
}
When I compile and run the program, this is what I see.
Only when user presses just one key from the keyboard, kbhit() returns 1.