Created
March 17, 2012 17:38
-
-
Save PhDP/2063259 to your computer and use it in GitHub Desktop.
Pause in C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: clang -Wall pause.c -o pause | |
#include <stdlib.h> | |
#include <stdio.h> | |
// Wait for the user to press enter to continue. | |
void pause(); | |
int main() | |
{ | |
fprintf(stdout, "Press enter to terminate this very useful program.\n"); | |
pause(); | |
return EXIT_SUCCESS; | |
} | |
void pause() | |
{ | |
// Flush the buffer | |
fflush(stdout); | |
int c; | |
while ((c = getchar()) != '\n' && c != EOF); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment