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
19
src/agg.c
19
src/agg.c
|
|
@ -5,6 +5,21 @@
|
|||
#include <stdlib.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 valid = 1;
|
||||
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);
|
||||
scanf("%s", input);
|
||||
if (isvalidnumber(input)) {
|
||||
if (isbool(input)) {
|
||||
sscanf(input, "%d", &tempInput);
|
||||
tutorial = tempInput;
|
||||
} else {
|
||||
|
|
@ -60,7 +75,7 @@ int main(void) {
|
|||
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);
|
||||
|
||||
if (isvalidnumber(input)) {
|
||||
if (isbool(input)) {
|
||||
sscanf(input, "%d", &accuracytype);
|
||||
} else {
|
||||
printf ("Error! An invalid character was entered.\n");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue