-
Notifications
You must be signed in to change notification settings - Fork 0
/
pause.h
38 lines (33 loc) · 800 Bytes
/
pause.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* ============================================================================
*
* Copyright 2017 Manoel Vilela
*
* Author: Manoel Vilela
* Contact: [email protected]
* Organization: UFC
*
* ============================================================================
**/
#ifndef PAUSE_H
#define PAUSE_H
#ifndef DS_UFC_H
#include <stdio.h>
#endif
/**
* @brief remove all the garbage from stdin
*/
static inline void flush_stdin() {
char c;
ungetc('\n', stdin); // ensure that stdin is dirty
while(((c = getchar()) != '\n') && (c != EOF));
}
/**
* @brief Cross-platform pause: works on windows and linux
*/
static inline void pause() {
printf("Press enter to continue...");
flush_stdin();
getchar();
}
#endif