Skip to content
Snippets Groups Projects

Final commit

1 file
+ 6
5
Compare changes
  • Side-by-side
  • Inline
+ 6
5
@@ -3,17 +3,18 @@
#include <string.h>
#include "main.h"
#include "tree.h"
#define INPUTSIZE 20
// You are allowed to change anything about this function to fix it
int main()
{
char *commandBuffer = (char *)malloc(sizeof(char) * 20);
char *commandBuffer = (char *)malloc(sizeof(char) * INPUTSIZE);
Tree *tree = tree_create();
for (;;)
{
fgets(commandBuffer, 20, stdin);
fgets(commandBuffer, INPUTSIZE, stdin);
// Quit on EOF or 'q'
if (feof(stdin) || commandBuffer == "q")
@@ -72,7 +73,7 @@ Tree *handleString(char command[], Tree *tree)
Tree *insert(char *command, Tree *tree)
{
int age;
char *name = malloc(sizeof(char) * 20);
char *name = malloc(sizeof(char) * INPUTSIZE);
if (2 != sscanf(command, "i %d %s", &age, name))
{
@@ -93,7 +94,7 @@ Tree *insert(char *command, Tree *tree)
void erase(char *command, Tree *tree)
{
int age;
char *name = malloc(sizeof(char) * 20);
char *name = malloc(sizeof(char) * INPUTSIZE);
if (2 != sscanf(command, "e %d %s", &age, name))
{
@@ -106,7 +107,7 @@ void erase(char *command, Tree *tree)
void check(char *command, Tree *tree)
{
int age;
char *name = malloc(sizeof(char) * 20);
char *name = malloc(sizeof(char) * INPUTSIZE);
if (2 != sscanf(command, "c %d %s", &age, name))
{
Loading