Update cv7/program.c
This commit is contained in:
parent
99de8b201c
commit
a834424976
@ -81,7 +81,10 @@ struct tree* read_tree() {
|
||||
|
||||
// Read a line from stdin
|
||||
char* r = fgets(buffer, SIZE, stdin);
|
||||
assert(r); // Ensure reading was successful
|
||||
if (r == NULL) {
|
||||
fprintf(stderr, "Error: Failed to read input\n");
|
||||
exit(1); // Exit the program if reading fails
|
||||
}
|
||||
|
||||
// Allocate memory for a new tree node
|
||||
struct tree* node = calloc(1, sizeof(struct tree));
|
||||
@ -105,6 +108,7 @@ struct tree* read_tree() {
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
int counter = 0;
|
||||
struct tree *root = read_tree(&counter); // Try reading the tree
|
||||
|
Loading…
Reference in New Issue
Block a user