22 lines
286 B
C
22 lines
286 B
C
|
#include "input.h"
|
||
|
|
||
|
int integer_input(char* val) {
|
||
|
|
||
|
int num;
|
||
|
char *error = "";
|
||
|
|
||
|
do {
|
||
|
printf("\n%s\n%s",error, val);
|
||
|
fflush(stdout);
|
||
|
|
||
|
char buf[128];
|
||
|
read(STDIN_FILENO, buf, 127);
|
||
|
num = atoi(buf);
|
||
|
|
||
|
error = "Input Error, try again.";
|
||
|
|
||
|
} while(!num);
|
||
|
|
||
|
return num;
|
||
|
}
|