don't continue on empty strings
This commit is contained in:
parent
c278da1705
commit
a6451e4904
1 changed files with 12 additions and 1 deletions
13
src/main.c
13
src/main.c
|
@ -48,14 +48,25 @@ int main(int argc, char *argv[]) {
|
|||
init_tables(elements, inv, polls, 1);
|
||||
|
||||
printf("%s, welcome to Elemental on Command Line!\n", name);
|
||||
int newline = 1;
|
||||
while (1) {
|
||||
// todo: separate into functions
|
||||
|
||||
printf("\n");
|
||||
if (newline) {
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
fgets(command, MAX_BUF_LENGTH - 1, stdin);
|
||||
|
||||
int cl = strlen(command);
|
||||
|
||||
if (cl < 2) {
|
||||
newline = 0;
|
||||
continue;
|
||||
} else {
|
||||
newline = 1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < cl - 1; i++) {
|
||||
command[i] = tolower(command[i]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue