This commit is contained in:
Oleksandr Vyshniakov 2025-11-20 16:50:03 +01:00
parent bd5281e52f
commit 8ade5298f1

View File

@ -38,6 +38,7 @@ static TreeNode* read_tree_node() {
node->yes_branch = read_tree_node();
node->no_branch = read_tree_node();
return node;
}
@ -99,6 +100,23 @@ static void skip_empty_line() {
}
}
static int has_more_data() {
char buffer[MAXLINE];
long pos = ftell(stdin);
if (fgets(buffer, sizeof(buffer), stdin) == NULL) {
return 0;
}
int newline = (buffer[0] == '\n' || buffer[0] == '\r');
if (!newline) {
return 1;
}
return 0;
}
static void run_dialog(TreeNode *root) {
if (root == NULL) {
return;
@ -139,7 +157,7 @@ int main() {
printf("Expert z bufetu to vie.\n");
if (root == NULL || !validate_tree(root)) {
if (root == NULL || !validate_tree(root) || has_more_data()) {
printf("Chybna databaza\n");
free_tree(root);
return 0;