Aktualizovat du5/program.c
This commit is contained in:
parent
057ae34354
commit
24ab3be1c3
@ -103,6 +103,7 @@ void goThroughTheTree(int rootIndex)
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
char buffer[SIZE];
|
char buffer[SIZE];
|
||||||
|
bool isErr; //pomocna error premena
|
||||||
|
|
||||||
//null-terminovanie
|
//null-terminovanie
|
||||||
buffer[0] = '\0';
|
buffer[0] = '\0';
|
||||||
@ -110,9 +111,11 @@ int main()
|
|||||||
// citanie vstupu
|
// citanie vstupu
|
||||||
while (fgets(buffer, SIZE, stdin))
|
while (fgets(buffer, SIZE, stdin))
|
||||||
{
|
{
|
||||||
//prestane citat vstup, ak je NEPLATNY
|
//prestane citat vstup, ak je NEPLATNY (rovna sa Newline symbolu, resp. prazdny riadok)
|
||||||
if (strcmp(buffer, "\n") == 0)
|
//ALEBO ak sa nenacital riadok vobec (buffer je uplne prazdny, (resp prvy prvok je null terminator))
|
||||||
|
if (strcmp(buffer, "\n") == 0 || buffer[0] = '\0')
|
||||||
{
|
{
|
||||||
|
isErr = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//nahradi NewLine symbol za null terminator (Newline sa prida naspat potom na konci programu)
|
//nahradi NewLine symbol za null terminator (Newline sa prida naspat potom na konci programu)
|
||||||
@ -132,12 +135,17 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("Expert z bufetu to vie.\n");
|
printf("Expert z bufetu to vie.\n");
|
||||||
printf("Pozna %d druhov ovocia a zeleniny.\n", answerCount);
|
if (!isErr) //vypise vysledky/statistiky, AK nebola chyba na zaciatku citania vstupu
|
||||||
printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n");
|
{
|
||||||
|
printf("Pozna %d druhov ovocia a zeleniny.\n", answerCount);
|
||||||
|
printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Chybna␣databaza");
|
||||||
|
}
|
||||||
|
|
||||||
goThroughTheTree(root);
|
goThroughTheTree(root);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user