Initializacia
This commit is contained in:
		
							parent
							
								
									6ec70db799
								
							
						
					
					
						commit
						3ecf143992
					
				| @ -13,16 +13,13 @@ struct tree { | ||||
| struct tree* read_tree() { | ||||
|     char buffer[SIZE]; | ||||
|     memset(buffer, 0, SIZE); | ||||
| 
 | ||||
|     if (!fgets(buffer, SIZE, stdin) || buffer[0] == '\n') { | ||||
|     char* r = fgets(buffer, SIZE, stdin); | ||||
|     if (!r || buffer[0] == '\n') { | ||||
|         return NULL; | ||||
|     } | ||||
| 
 | ||||
|     buffer[strcspn(buffer, "\n")] = 0; | ||||
| 
 | ||||
|     struct tree* node = (struct tree*)calloc(1, sizeof(struct tree)); | ||||
|     buffer[strcspn(buffer, "\n")] = 0;  | ||||
|     struct tree* node = calloc(1, sizeof(struct tree)); | ||||
|     strncpy(node->value, buffer, SIZE - 1); | ||||
| 
 | ||||
|     return node; | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user