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