2023-10-13 03:29:13 -07:00
|
|
|
#include "input.h"
|
|
|
|
|
|
|
|
int integer_input(char* val) {
|
|
|
|
|
|
|
|
int num;
|
|
|
|
char *error = "";
|
|
|
|
|
|
|
|
do {
|
2023-10-14 16:57:09 -07:00
|
|
|
printf("%s\n%s",error, val);
|
2023-10-13 03:29:13 -07:00
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
char buf[128];
|
|
|
|
read(STDIN_FILENO, buf, 127);
|
|
|
|
num = atoi(buf);
|
|
|
|
|
2023-10-14 16:57:09 -07:00
|
|
|
error = "\nInput Error, try again.";
|
2023-10-13 03:29:13 -07:00
|
|
|
|
|
|
|
} while(!num);
|
|
|
|
|
|
|
|
return num;
|
|
|
|
}
|