Compare commits
No commits in common. "181a0f3dcd51091b95e84695b8ad8d8ce7bcd722" and "d404fc122e3ac81326f0d1b2c27b13093606ec35" have entirely different histories.
181a0f3dcd
...
d404fc122e
@ -1,14 +1,11 @@
|
|||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
const char * PROMPT = "ml' nob:";
|
const char * PROMPT = "ml' nob:";
|
||||||
|
|
||||||
const char * INPUT_OKAY = "Qapla'";
|
const char * INPUT_OKAY = "Qapla'";
|
||||||
|
|
||||||
const char * OUT_OF_RANGE = "Qih mi'";
|
const char * OUT_OF_RANGE = "Qih mi'";
|
||||||
const char * NOT_A_NUMBER = "Neh mi'";
|
const char * NOT_A_NUMBER = "Neh mi'";
|
||||||
const char * INVALID_NUMBER = "bIjatlh 'e' yImev";
|
|
||||||
|
|
||||||
const char * QUOTES[9] = {
|
const char * QUOTES[9] = {
|
||||||
"noH QapmeH wo' Qaw'lu'chugh yay chavbe'lu' 'ej wo' choqmeH may' DoHlu'chugh lujbe'lu'.",
|
"noH QapmeH wo' Qaw'lu'chugh yay chavbe'lu' 'ej wo' choqmeH may' DoHlu'chugh lujbe'lu'.",
|
||||||
@ -23,29 +20,18 @@ const char * QUOTES[9] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
char *buf = NULL;
|
int input = 0;
|
||||||
size_t len = 0;
|
|
||||||
char* end;
|
|
||||||
|
|
||||||
printf("%s\n", PROMPT);
|
printf("%s\n", PROMPT);
|
||||||
|
int result = scanf("%d", &input);
|
||||||
|
|
||||||
ssize_t chars_read = getline(&buf, &len, stdin);
|
if(result != 1) {
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
long input = strtol(buf, &end, 10);
|
|
||||||
|
|
||||||
if(errno == ERANGE || chars_read == -1 || end == &buf[0]) {
|
|
||||||
printf("%s\n", NOT_A_NUMBER);
|
printf("%s\n", NOT_A_NUMBER);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(*end != '\n') {
|
|
||||||
printf("%s\n", INVALID_NUMBER);
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(input < 0 || input > 8) {
|
if(input < 0 || input > 8) {
|
||||||
printf("%s %ld\n", OUT_OF_RANGE, input);
|
printf("%s %d\n", OUT_OF_RANGE, input);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
1.123
|
|
@ -1,2 +0,0 @@
|
|||||||
ml' nob:
|
|
||||||
bIjatlh 'e' yImev
|
|
File diff suppressed because one or more lines are too long
@ -1,2 +0,0 @@
|
|||||||
ml' nob:
|
|
||||||
bIjatlh 'e' yImev
|
|
@ -1 +0,0 @@
|
|||||||
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002
|
|
@ -1,3 +0,0 @@
|
|||||||
ml' nob:
|
|
||||||
Qapla'
|
|
||||||
Qu' buSHa'chugh SuvwI', batlhHa' vangchugh, qoj matlhHa'chugh, pagh ghaH SuvwI''e'.
|
|
Loading…
x
Reference in New Issue
Block a user