nepodarilo nacitat nic

This commit is contained in:
Michal Utľák 2024-03-13 12:37:24 +01:00
parent f41f431402
commit dc8ec1bd4d

View File

@ -20,23 +20,34 @@ char line[SIZE];
int main() { int main() {
memset(databaza, 0, SIZE * sizeof(struct student)); memset(databaza, 0, SIZE * sizeof(struct student));
int prvy_vstup = 1; int prvyInput = 1;
while (1) { while (1) {
memset(line, 0, SIZE); memset(line, 0, SIZE);
char *r = fgets(line, SIZE, stdin); char *r = fgets(line, SIZE, stdin);
if (r == NULL) { if (r == NULL) {
break; if(prvyInput){
printf("Nepodarilo nacitat nic\n");
return 0;
}
else{
break;
}
} }
if (strcmp(line, "\n") == 0) { if (strcmp(line, "\n") == 0) {
continue; if (prvyInput) {
printf("Nepodarilo nacitat nic\n");
return 0;
} else {
continue;
}
} }
int value = strtol(line, NULL, 10); int value = strtol(line, NULL, 10);
if (value == 0) { if (value == 0) {
if (prvy_vstup) { if (prvyInput) {
printf("Nepodarilo nacitat nic\n"); printf("Nepodarilo nacitat nic\n");
return 0; return 0;
} else { } else {
@ -44,7 +55,7 @@ int main() {
} }
} }
prvy_vstup = 0; prvyInput = 0;
char name[SIZE]; char name[SIZE];
memset(name, 0, SIZE); memset(name, 0, SIZE);