refresh
This commit is contained in:
parent
bd5281e52f
commit
8ade5298f1
@ -38,6 +38,7 @@ static TreeNode* read_tree_node() {
|
|||||||
|
|
||||||
node->yes_branch = read_tree_node();
|
node->yes_branch = read_tree_node();
|
||||||
node->no_branch = read_tree_node();
|
node->no_branch = read_tree_node();
|
||||||
|
|
||||||
return 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) {
|
static void run_dialog(TreeNode *root) {
|
||||||
if (root == NULL) {
|
if (root == NULL) {
|
||||||
return;
|
return;
|
||||||
@ -139,7 +157,7 @@ int main() {
|
|||||||
|
|
||||||
printf("Expert z bufetu to vie.\n");
|
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");
|
printf("Chybna databaza\n");
|
||||||
free_tree(root);
|
free_tree(root);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user