Skip to content

Instantly share code, notes, and snippets.

@PhDP
Created March 17, 2012 17:38
Show Gist options
  • Save PhDP/2063259 to your computer and use it in GitHub Desktop.
Save PhDP/2063259 to your computer and use it in GitHub Desktop.
Pause in C
//: 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