mirror of
https://github.com/Soccera1/agg.git
synced 2025-11-04 10:27:33 +01:00
Compare commits
5 commits
effe06fca4
...
51e7266911
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51e7266911 | ||
|
|
34a6070190 | ||
|
|
a950c86624 | ||
|
|
7ad41ef827 | ||
|
|
e1e16a1566 |
1 changed files with 18 additions and 3 deletions
21
src/agg.c
21
src/agg.c
|
|
@ -5,6 +5,21 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
int isbool(char entered []) {
|
||||||
|
int valid = 1;
|
||||||
|
for (int i = 0; i < strlen(entered); i++) {
|
||||||
|
switch (entered[i]) {
|
||||||
|
case '0':
|
||||||
|
case '1':
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
valid = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
int isvalidnumber(char entered []) {
|
int isvalidnumber(char entered []) {
|
||||||
int valid = 1;
|
int valid = 1;
|
||||||
for (int i = 0; i < strlen(entered); i++) {
|
for (int i = 0; i < strlen(entered); i++) {
|
||||||
|
|
@ -44,7 +59,7 @@ int main(void) {
|
||||||
|
|
||||||
printf ("Hello %s!\nThis is a game written for AgnoxGD.\nWould you like to see a tutorial\nType 1 for no, or 0 for yes.\n", username);
|
printf ("Hello %s!\nThis is a game written for AgnoxGD.\nWould you like to see a tutorial\nType 1 for no, or 0 for yes.\n", username);
|
||||||
scanf("%s", input);
|
scanf("%s", input);
|
||||||
if (isvalidnumber(input)) {
|
if (isbool(input)) {
|
||||||
sscanf(input, "%d", &tempInput);
|
sscanf(input, "%d", &tempInput);
|
||||||
tutorial = tempInput;
|
tutorial = tempInput;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -58,9 +73,9 @@ int main(void) {
|
||||||
|
|
||||||
int accuracytype;
|
int accuracytype;
|
||||||
printf ("\nWould you like your accuracy as a float or as an int? Type 0 for float or 1 for int.\n");
|
printf ("\nWould you like your accuracy as a float or as an int? Type 0 for float or 1 for int.\n");
|
||||||
scanf ("%s", input);
|
scanf ("%s", input);
|
||||||
|
|
||||||
if (isvalidnumber(input)) {
|
if (isbool(input)) {
|
||||||
sscanf(input, "%d", &accuracytype);
|
sscanf(input, "%d", &accuracytype);
|
||||||
} else {
|
} else {
|
||||||
printf ("Error! An invalid character was entered.\n");
|
printf ("Error! An invalid character was entered.\n");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue