diff --git a/du5/program.c b/du5/program.c index 71d3081..5c2cd2d 100644 --- a/du5/program.c +++ b/du5/program.c @@ -39,7 +39,8 @@ int buildATree() int current = nodeCount; nodeCount += 1; - if (line[0] == '*') { + if (line[0] == '*') + { tree[current].isAnswer = true; strcpy(tree[current].text, line + 1); tree[current].yes = invalidIndex; @@ -77,7 +78,11 @@ void goThroughTheTree(int rootIndex) printf("%s\n", tree[current].text); //nacitanie odpovedi (jeden char) - scanf(" %c", &input); + if (scanf(" %c", &input) != 1) + { + printf("Koniec vstupu\n"); + return; + } if (input == 'a') {