criyle/codenet-compile-errors huggingface dataset:
Language: C

#include<stdio.h>
typedef NIL{
  int r,l;
}struct;
NIL x,y;
void insert(T,z){
  y = NIL;
  x = T;
  if(z=key<x<key)x = x.left;
  else{
    x = x.r;
  }
  z.p = y;
  if(y == -1){
    T = z;
  }
  else if(z.key < y.key){
    y.left = z;
  }
  else{
    y.r = z;
  }
}
  
int main(){
  int n,i;
  scanf("%d", &n);
  int P[n];
  for(i=0;i<n-1;i++){
    printf("insert ");
    scanf("%d", &P[i]);
  }
  printf("print\n");

  
  return 0;
}

Compiler output:
main.c:2:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
    2 | typedef NIL{
      |            ^
main.c:4:8: error: expected '{' before ';' token
    4 | }struct;
      |        ^
main.c:5:1: error: unknown type name 'NIL'
    5 | NIL x,y;
      | ^~~
main.c: In function 'insert':
main.c:6:6: error: type of 'T' defaults to 'int' [-Wimplicit-int]
    6 | void insert(T,z){
      |      ^~~~~~
main.c:6:6: error: type of 'z' defaults to 'int' [-Wimplicit-int]
main.c:7:7: error: 'NIL' undeclared (first use in this function)
    7 |   y = NIL;
      |       ^~~
main.c:7:7: note: each undeclared identifier is reported only once for each function it appears in
main.c:9:8: error: 'key' undeclared (first use in this function)
    9 |   if(z=key<x<key)x = x.left;
      |        ^~~
main.c:9:23: error: request for member 'left' in something not a structure or union
    9 |   if(z=key<x<key)x = x.left;
      |                       ^
main.c:11:10: error: request for member 'r' in something not a structure or union
   11 |     x = x.r;
      |          ^
main.c:13:4: error: request for member 'p' in something not a structure or union
   13 |   z.p = y;
      |    ^
main.c:17:12: error: request for member 'key' in something not a structure or union
   17 |   else if(z.key < y.key){
      |            ^
main.c:17:20: error: request for member 'key' in something not a structure or union
   17 |   else if(z.key < y.key){
      |                    ^
main.c:18:6: error: request for member 'left' in something not a structure or union
   18 |     y.left = z;
      |      ^
main.c:21:6: error: request for member 'r' in something not a structure or union
   21 |     y.r = z;
      |      ^
Language: C

#include<stdio.h>
#include<stdlib.h>
#define N NULL

struct node{
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
};
typedef struct node * Node;

Node root;
void insert(int);
void inorder(Node );
void preorder(Node );

int main(){
  int s, i, x;
  char c[10];

  scanf("%d", &s);

  for(i=0; i<s; i++){
    scanf("%s", c);
    if( c[0] == 'i'){
      scanf("%d", &x);
      insert(x);
    }
    if( c[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

void insert(int k){
  Node y = N;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = N;
  z->r = N;

  while(x != N){
    y = x;
    if(z->key < x->key) x = x->l;
    else x = x->r;
  }
  
  z->p = y;
  if(y == N) root = z;
  else if(z->key < y->key) y->l = z;
  else y->r = z;
}

void inorder(Node u){
  if(u != N){
    inorder(u->l);
    printf(" %d",u->key);
    inorder(u -> r);
  }
}
void preoder(Node u){
  if(u != N){
    printf(" %d",u->key);
    preorder(u->l);
    preorder(u->r);
  }
}

Compiler output:
/usr/bin/ld: /tmp/ccWtWoWC.o: in function `main':
main.c:(.text+0xa3): undefined reference to `preorder'
/usr/bin/ld: /tmp/ccWtWoWC.o: in function `preoder':
main.c:(.text+0x22d): undefined reference to `preorder'
/usr/bin/ld: main.c:(.text+0x23c): undefined reference to `preorder'
collect2: error: ld returned 1 exit status
Language: C

Node treeMinimum(Node x){
  while(x.left != NIL) {
    x = x.left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x.right != NIL) {
    x = x.right;
  }
  return x;

Compiler output:
main.c:1:1: error: unknown type name 'Node'
    1 | Node treeMinimum(Node x){
      | ^~~~
main.c:1:18: error: unknown type name 'Node'
    1 | Node treeMinimum(Node x){
      |                  ^~~~
main.c:8:1: error: unknown type name 'Node'
    8 | Node treeMaximum(Node x){
      | ^~~~
main.c:8:18: error: unknown type name 'Node'
    8 | Node treeMaximum(Node x){
      |                  ^~~~
Language: C

#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;


Node treeSearch(Node u, int k){
  if(x == NIL || k == x.key) return x;
  if(k < x.key) return treeSearch(x.left,k);
  else return treeSreach(x.right,k);

}


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key<x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
   
  if(y==NIL) root = z;
  else if(z->key<y->key) y->left = z;
  else y->right = z;



}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL) return;
    printf(" %d",u->key);
    preorderTreeWalk(u->left);
    preorderTreeWalk(u->right); 
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}

Compiler output:
main.c: In function 'treeSearch':
main.c:17:6: error: 'x' undeclared (first use in this function)
   17 |   if(x == NIL || k == x.key) return x;
      |      ^
main.c:17:6: note: each undeclared identifier is reported only once for each function it appears in
main.c:19:15: error: implicit declaration of function 'treeSreach'; did you mean 'treeSearch'? [-Wimplicit-function-declaration]
   19 |   else return treeSreach(x.right,k);
      |               ^~~~~~~~~~
      |               treeSearch
main.c: In function 'preorder':
main.c:57:5: error: implicit declaration of function 'preorderTreeWalk' [-Wimplicit-function-declaration]
   57 |     preorderTreeWalk(u->left);
      |     ^~~~~~~~~~~~~~~~
Language: C

 if(u!=NIL){
    if(u->left!=NIL){
      inorder(u->left);
    }
    printf(" %d",u->key);
       
    if(u->right!=NIL){
      inorder(u->right);
    }
  }

Compiler output:
main.c:1:2: error: expected identifier or '(' before 'if'
    1 |  if(u!=NIL){
      |  ^~
Language: C

#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;


Node treeSearch(Node u, int k){
  if(x == NIL || k == x->key) return x;
  if(k < x->key) return treeSearch(x->left,k);
  else return treeSreach(x->right,k);

}


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key<x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
   
  if(y==NIL) root = z;
  else if(z->key<y->key) y->left = z;
  else y->right = z;



}

void inorder(Node u){
 if(u!=NIL){
    if(u->left!=NIL) inorder(u->left);
    
    printf(" %d",u->key);
       
    if(u->right!=NIL) inorder(u->right);
   }
}
void preorder(Node u){
   printf(" %d",u->key);
  if(u!=NIL){
    if(u->left!=NIL) preorder(u->left);
    
    if(u->right!=NIL) preorder(u->right); 
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}

Compiler output:
main.c: In function 'treeSearch':
main.c:17:6: error: 'x' undeclared (first use in this function)
   17 |   if(x == NIL || k == x->key) return x;
      |      ^
main.c:17:6: note: each undeclared identifier is reported only once for each function it appears in
main.c:19:15: error: implicit declaration of function 'treeSreach'; did you mean 'treeSearch'? [-Wimplicit-function-declaration]
   19 |   else return treeSreach(x->right,k);
      |               ^~~~~~~~~~
      |               treeSearch
Language: C

#include<stdio.h>
#include<stdlib.h>
 
#define NIL NULL
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};



typedef struct node * Node;
  
Node root;
 
void treeD(Node);
void treeInsert(int);
void inorder(Node);
void preorder(Node);
Node treeMin(Node);
Node treeS(Node,int);
Node treeSuc(Node);



int main(){
 
  int res, i, alt;
 
  char com[20];
   
  scanf("%d", &res);
  
  for (i = 0;i < res;i ++ )
    {
    scanf("%s", com);
 
    if (com[0] == 'f' )
      {
    scanf("%d", &x);
    Node t = treeS(root, alt);
    if ( t != NIL ) printf("yes\n");
    else printf("no\n");
      }
    else if ( com[0] == 'i' )
      {
    scanf("%d", &x);
    treeInsert(x);
      }
    else if ( com[0] == 'p' )
      {
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n");
      }
    else if ( com[0] == 'd' )
      {
    scanf("%d", &alt);
    treeD(treeS(root, alt));
      }
    }
  return 0;
}



 
Node treeMin(Node x){
 
  while(x->left != NIL)
    {
      x = x->left;
    }
  return x;
}


  
Node treeS(Node u, int k){
 
  if(u == NIL || k == u->key)
    {
      return u;
    }
   
  if(k < u->key)
    {
      return treeS(u->left, k);
    }
  else{
    return treeS(u->right,k);
  }
}


 
Node treeSuc(Node x){
 
  Node y;
   
  if(x->right != NIL)
    {
      return treeMin(x->right);
    }
   
  y = x->parent;
 
  while(y != NIL && x == y->right)
    {
      x = y;
      y = y->parent;
    }
  return y;
}


 
void treeD(Node z){
  Node y; 
  Node x; 
}


  
void treeInsert(int r){
 
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
 
  z->key = r;
  z->left = NIL;
  z->right = NIL;
  
  while (x!=NIL)
    {
      y = x;
      if (z->key < x->key)
    {
      x = x->left;
    }
      else {
    x = x->right;
      }
    }
   
  z->parent = y;
   
  if(y == NIL)
    {
      root = z;
    }
  else if(z->key < y->key)
    {
      y->left = z;
    }
  else{
    y->right = z;
  }
   
}



void inorder(Node n){
 
  if (n != NIL)
    {
      inorder(n->left);
      printf(" %d",n->key);
      inorder(n->right);
    }
}


 
void preorder(Node u){
 
  if (u != NIL)
    {
      printf(" %d",u->key);
      preorder(u->left);
      preorder(u->right);
    }

  
}

Compiler output:
main.c: In function 'main':
main.c:43:18: error: 'x' undeclared (first use in this function)
   43 |     scanf("%d", &x);
      |                  ^
main.c:43:18: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
#include<stdlib.h>
#define N NULL

struct node{
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
};
typedef struct node * Node;

Node root;
void insert(int);
void inorder(Node );
void preorder(Node );

int main(){
  int s, i, x;
  char c[10];

  scanf("%d", &s);

  for(i=0; i<s; i++){
    scanf("%s", c);
    if( c[0] == 'i'){
      scanf("%d", &x);
      insert(x);
    }
    if( c[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

void insert(int k){
  Node y = N;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = N;
  z->r = N;

  while(x != N){
    y = x;
    if(z->key < x->key) x = x->l;
    else x = x->r;
  }
  
  z->p = y;
  if(y == N) root = z;
  else if(z->key < y->key) y->l = z;
  else y->r = z;
}

void inorder(Node u){
  if(u != N){
    inorder(u->l);
    printf(" %d",u->key);
    inorder(u -> r);
  }
}
void preoder(Node u){
  if(u != N){
    printf(" %d",u->key);
    preorder(u->l);
    preorder(u->r);
  }
}

Compiler output:
/usr/bin/ld: /tmp/ccfXNT9v.o: in function `main':
main.c:(.text+0xa3): undefined reference to `preorder'
/usr/bin/ld: /tmp/ccfXNT9v.o: in function `preoder':
main.c:(.text+0x22d): undefined reference to `preorder'
/usr/bin/ld: main.c:(.text+0x23c): undefined reference to `preorder'
collect2: error: ld returned 1 exit status
Language: C

#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;


Node treeSearch(Node x, int k){
  if(x == NIL || k == x->key) return x;
  if(k < x->key) return treeSearch(x->left,k);
  else return treeSreach(x->right,k);

}


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key<x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
   
  if(y==NIL) root = z;
  else if(z->key<y->key) y->left = z;
  else y->right = z;



}

void inorder(Node u){
 if(u!=NIL){
    if(u->left!=NIL) inorder(u->left);
    
    printf(" %d",u->key);
       
    if(u->right!=NIL) inorder(u->right);
   }
}
void preorder(Node u){
   printf(" %d",u->key);
  if(u!=NIL){
    if(u->left!=NIL) preorder(u->left);
    
    if(u->right!=NIL) preorder(u->right); 
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}

Compiler output:
main.c: In function 'treeSearch':
main.c:19:15: error: implicit declaration of function 'treeSreach'; did you mean 'treeSearch'? [-Wimplicit-function-declaration]
   19 |   else return treeSreach(x->right,k);
      |               ^~~~~~~~~~
      |               treeSearch
main.c:19:15: error: returning 'int' from a function with return type 'Node' {aka 'struct node *'} makes pointer from integer without a cast [-Wint-conversion]
   19 |   else return treeSreach(x->right,k);
      |               ^~~~~~~~~~~~~~~~~~~~~~
Language: C

#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;

}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;

}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key) return u;

  if(k < u->key) return treeSearch(u->left, k);
  else return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  Node y;
  
  if(x->right != NIL) return treeMinimum(x->right);

  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL) x = y->left;
  else x = y->right;

  if(x != NIL) x->parent = y->parent;

  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;

  if(y != z) z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  
  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;

}

void inorder(Node u){
  if(u == NIL) return;

  inoder(u->left);
  printf("%d ",u->key);
  inoder(u->right);
	 
}
void preorder(Node u){
  if(u == NIL) return;

  printf("%d ",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Compiler output:
main.c: In function 'inorder':
main.c:99:3: error: implicit declaration of function 'inoder'; did you mean 'inorder'? [-Wimplicit-function-declaration]
   99 |   inoder(u->left);
      |   ^~~~~~
      |   inorder
Language: C

#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *r;
  struct node *l;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;
 
  while(x!=NIL){
    y = x;
    if(z->key < x->key) x = x->l;
    else x = x->right;
  }
  z->parent = y;
  if(y==NIL) root = z;
  else if(z->key < y->key) y->l = z;
  else y->r = z;
}
 
void inorder(Node u){
  if(u !=NIL){
    inorder(u->l);
    printf(" %d",u->key);
    inorder(u->r);
  }
}
 
void preorder(Node u){
  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->l);
    preorder(u->r);
  }
}
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if (com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
 
  return 0;
}

Compiler output:
main.c: In function 'insert':
main.c:27:15: error: 'struct node' has no member named 'right'
   27 |     else x = x->right;
      |               ^~
Language: C

#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

 
  while(x!=NIL){
    y=x;
    if(z->key<x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->parent = y;
 
  if(y==NIL)
    root = z;
  else if(z->key<y->key)
    y->left = z;
  else
    y->right = z;
 
}


}

void inorder(Node u){
 if(x==NIL)
    return;
   
  inorderTreeWalk(x->left);
  printf(" %d",x->key);
  inorderTreeWalk(x->right);
}
void preorder(Node u){
 if(x==NIL)
    return;
   
    printf(" %d",x->key);
    preorderTreeWalk(x->left);
    preorderTreeWalk(x->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Compiler output:
main.c:73:1: error: expected identifier or '(' before '}' token
   73 | }
      | ^
main.c: In function 'inorder':
main.c:76:5: error: 'x' undeclared (first use in this function)
   76 |  if(x==NIL)
      |     ^
main.c:76:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:79:3: error: implicit declaration of function 'inorderTreeWalk' [-Wimplicit-function-declaration]
   79 |   inorderTreeWalk(x->left);
      |   ^~~~~~~~~~~~~~~
main.c: In function 'preorder':
main.c:84:5: error: 'x' undeclared (first use in this function)
   84 |  if(x==NIL)
      |     ^
main.c:88:5: error: implicit declaration of function 'preorderTreeWalk' [-Wimplicit-function-declaration]
   88 |     preorderTreeWalk(x->left);
      |     ^~~~~~~~~~~~~~~~
Language: C

#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

 
  while(x!=NIL){
    y=x;
    if(z->key<x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->parent = y;
 
  if(y==NIL)
    root = z;
  else if(z->key<y->key)
    y->left = z;
  else
    y->right = z;
 
}

void inorder(Node u){
 if(u==NIL)
    return;
   
  inorderTreeWalk(u->left);
  printf(" %d",u->key);
  inorderTreeWalk(u->right);
}
void preorder(Node u){
 if(u==NIL)
    return;
   
    printf(" %d",u->key);
    preorderTreeWalk(u->left);
    preorderTreeWalk(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Compiler output:
main.c: In function 'inorder':
main.c:76:3: error: implicit declaration of function 'inorderTreeWalk' [-Wimplicit-function-declaration]
   76 |   inorderTreeWalk(u->left);
      |   ^~~~~~~~~~~~~~~
main.c: In function 'preorder':
main.c:85:5: error: implicit declaration of function 'preorderTreeWalk' [-Wimplicit-function-declaration]
   85 |     preorderTreeWalk(u->left);
      |     ^~~~~~~~~~~~~~~~
Language: C

#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){

  while(x->left!=NIL){
    x = x->left;
    return x;
  }

}

Node treeMaximum(Node x){

  while(x->right!=NIL){
    x = x->right;
    return x;
  }

}

Node treeSearch(Node u, int k){

  if(x==NIL || k==x.key){
    return x
      }
  if(k<x->key){
    return treeSearch(x.left,k){
    }
    else{
      return treeSearch(x.right,k)
	}
}

Node treeSuccessor(Node x){

  if(x->right !=NIL){
    return treeMinimum(x->right);
  }
  y=x->p;
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;




}

void inorder(Node u){
  if(u!=NIL){
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
 }
}
 
  
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!=NIL)preorder(u->left);
  if(u->right!=NIL) preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Compiler output:
main.c: In function 'treeSearch':
main.c:35:6: error: 'x' undeclared (first use in this function)
   35 |   if(x==NIL || k==x.key){
      |      ^
main.c:35:6: note: each undeclared identifier is reported only once for each function it appears in
main.c:36:13: error: expected ';' before '}' token
   36 |     return x
      |             ^
      |             ;
   37 |       }
      |       ~      
main.c:39:32: error: expected ';' before '{' token
   39 |     return treeSearch(x.left,k){
      |                                ^
      |                                ;
main.c: In function 'treeSuccessor':
main.c:51:3: error: 'y' undeclared (first use in this function)
   51 |   y=x->p;
      |   ^
main.c:51:6: error: 'struct node' has no member named 'p'
   51 |   y=x->p;
      |      ^~
main.c: In function 'treeSearch':
main.c:122:1: error: expected declaration or statement at end of input
  122 | }
      | ^
Language: C

#include <iostream>
??
using namespace std;
??
struct Node{
????int ke;
????Node *par;
????Node *rig;
????Node *lef;
};
??
Node *ro,*ni;
??????
void insert(int k){
????Node *a=ro, *b=ni, *c;
??
????c = new Node;
????c->ke=k;
????c->rig=c->lef=ni;
??
????while(a!=ni){
????????b=a;
????????if(c->ke < a->ke) a=a->lef;
????????else a=a->rig;
????}
????c->par = b;
??
????if(b==ni) ro=c;
????else if(c->ke < b->ke) b->lef=c;
????else b->rig=c;
}
??
void preo(Node *r){
????if(r==ni) return;
????cout << " " << r->ke;
????preo(r->lef);
????preo(r->rig);?? 
}
??
void ino(Node *r){
????if(r==ni) return;
????ino(r->lef);
????cout << " " << r->ke;
????ino(r->rig);
}
??
int main(){
????int x,y;
????string str;
??
????cin >> x;
????for(int i=0;i<x;i++){
????????cin >> str;
????????if(str=="insert"){
????????????cin >> y;
????????????insert(y);
????????}
????????else if(str=="print"){
????????????ino(ro);
????????????cout << endl;
????????????preo(ro);
????????????cout << endl;
????????}
????}
??
????return 0;
}

Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C

#include<stdio.h>
#include<stdlib.h>
#define NI NULL
??
struct node{
????int key;
????struct node *rig;
????struct node *lef;
????struct node *par;
};
??
typedef struct node * Node;
??
Node root;
??
void insert(int v){
????Node a=NI;
????Node b=root;
????Node c;
??
????c=malloc(sizeof(struct node));
????c->key=v;
????c->lef=NI;
????c->rig=NIL;
??
????while(b!=NI){
????????a=b;
??
????????if(c->key < b->key) b=b->lef;
????????else b=b->rig;
????}
??
????????c->par=a;
??
????????if(a==NI) root=c;
????????else if(c->key < a->key) a->lef=c;
????????else a->rig=c;
}
??
void inorder(Node u){
????if(u!=NI){
????????inorder(u->lef);
????????printf(" %d",u->key);
????????inorder(u->rig);
????}
}
void preorder(Node u){
????if(u!=NI){
????????printf(" %d",u->key);
????????preorder(u->lef);
????????preorder(u->rig);
????}
}
??
int main(){
????int k,i,x;
????char com[20];
??
????scanf("%d",&k);
??
????for(i=0;i<k;i++){
????????scanf("%s",com);
??
????if(com[0]=='i'){
????????scanf("%d",&x);
????????insert(x);
????}
????else if(com[0]=='p'){
????????inorder(root);
????????printf("\n");
????????preorder(root);
????????printf("\n");
????}
????}
????return 0;
}

Compiler output:
main.c:4:1: error: expected identifier or '(' before '?' token
    4 | ??
      | ^
main.c:11:1: error: expected identifier or '(' before '?' token
   11 | ??
      | ^
main.c:13:1: error: expected identifier or '(' before '?' token
   13 | ??
      | ^
main.c:15:1: error: expected identifier or '(' before '?' token
   15 | ??
      | ^
main.c:39:1: error: expected identifier or '(' before '?' token
   39 | ??
      | ^
main.c:47:15: error: unknown type name 'Node'
   47 | void preorder(Node u){
      |               ^~~~
main.c:54:1: error: expected identifier or '(' before '?' token
   54 | ??
      | ^
Language: C

#include <stdio.h>
#include <stdlib.h>
??
struct node{
????struct node *right;
????struct node *left;
????struct node *parent;
????int key;
};
??
typedef struct node * Node;
??
#define NIL NULL
??
void insert(int);
void inorder(Node);
void preorder(Node);
??
Node root;
??
int main(){
??
????int n, i, x;
??
????scanf("%d", &n);
??
????for ( i = 0; i < n; i++ ){
??????printf("insert ");
????????????scanf("%d", &x);
????????????insert(x);

????????????inorder(root);
????????????printf("\n");
????????????preorder(root);
????????????printf("\n");
????????
????}
??
????return 0;
}
??
void insert(int k){
??
????Node y = NIL;
????Node x = root;
????Node z;
??
????z = malloc(sizeof(struct node));
????z->key = k;
????z->left = NIL;
????z->right = NIL;
??
????
????while(x != NIL){
??
????????y = x;
??
????????if(z->key < x->key){
????????????x = x->left;
????????}
??
????????else{
????????????x = x->right;
????????}
????}
??
????z->parent = y;
??
????if(y == NIL){
????????root = z;
????}
??
????else if(z->key < y->key){
????????y->left = z;
????}
??
????else y->right = z;
??
}
??
void inorder(Node u){
??
????if(u != NIL){
????????inorder(u->left);
????????printf(" %d", u->key);
????????inorder(u->right);
????}
??
}
??
void preorder(Node u){
??
????if(u != NIL){
????????printf(" %d",u->key);
????????preorder(u->left);
????????preorder(u->right);
????}
??
}

Compiler output:
main.c:3:1: error: expected identifier or '(' before '?' token
    3 | ??
      | ^
main.c:10:1: error: expected identifier or '(' before '?' token
   10 | ??
      | ^
main.c:12:1: error: expected identifier or '(' before '?' token
   12 | ??
      | ^
main.c:16:1: error: parameter names (without types) in function declaration [-Wdeclaration-missing-parameter-type]
   16 | void inorder(Node);
      | ^~~~
main.c:17:1: error: parameter names (without types) in function declaration [-Wdeclaration-missing-parameter-type]
   17 | void preorder(Node);
      | ^~~~
main.c:18:1: error: expected identifier or '(' before '?' token
   18 | ??
      | ^
main.c:20:1: error: expected identifier or '(' before '?' token
   20 | ??
      | ^
main.c:41:1: error: expected identifier or '(' before '?' token
   41 | ??
      | ^
main.c:80:1: error: expected identifier or '(' before '?' token
   80 | ??
      | ^
main.c:90:1: error: expected identifier or '(' before '?' token
   90 | ??
      | ^
Language: C

#include<stdio.h>
#include<stdlib.h>

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);

    if (com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }

  }

  return 0;
}

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right!=NIL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){

  if(u==NIL||k==u->key) return u;
  if(k<u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL) return treeMinimum(x->right);

  y = x->parent;
  while(y!=NIL && x==y->right){
    x = y;
    y = y->parent;
  }
  return y;
}
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y = x;
    if(z->key<x->key) x=x->left;
    else x=x->right;
  }
  z->parent = y;

  if(y==NIL) root=z;
  else if(z->key<y->key) y->left=z;
  else y->right=z;
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){

  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

Compiler output:
main.c: In function 'main':
main.c:14:7: error: implicit declaration of function 'insert' [-Wimplicit-function-declaration]
   14 |       insert(x);
      |       ^~~~~~
main.c:17:7: error: implicit declaration of function 'inorder' [-Wimplicit-function-declaration]
   17 |       inorder(root);
      |       ^~~~~~~
main.c:17:15: error: 'root' undeclared (first use in this function)
   17 |       inorder(root);
      |               ^~~~
main.c:17:15: note: each undeclared identifier is reported only once for each function it appears in
main.c:19:7: error: implicit declaration of function 'preorder' [-Wimplicit-function-declaration]
   19 |       preorder(root);
      |       ^~~~~~~~
main.c: At top level:
main.c:72:6: warning: conflicting types for 'insert'; have 'void(int)'
   72 | void insert(int k){
      |      ^~~~~~
main.c:14:7: note: previous implicit declaration of 'insert' with type 'void(int)'
   14 |       insert(x);
      |       ^~~~~~
main.c:94:6: warning: conflicting types for 'inorder'; have 'void(struct node *)'
   94 | void inorder(Node u){
      |      ^~~~~~~
main.c:17:7: note: previous implicit declaration of 'inorder' with type 'void(struct node *)'
   17 |       inorder(root);
      |       ^~~~~~~
main.c:101:6: warning: conflicting types for 'preorder'; have 'void(struct node *)'
  101 | void preorder(Node u){
      |      ^~~~~~~~
main.c:19:7: note: previous implicit declaration of 'preorder' with type 'void(struct node *)'
   19 |       preorder(root);
      |       ^~~~~~~~
Language: C

#include <stdio.h>
#include <stdlib.h>
   
typedef struct{
    int key;
    int left;
    int right;
} Node;
   
void insert(Node*, int, int);
void print1(Node*, int);
void print2(Node*, int);
   
int main()
{
    char s[10];
    Node *t;
    int m;
    int a;
    int i;
    int cnt=0;   

    scanf("%d", &m);

    t=(Node*)malloc(sizeof(Node)*m);
   
    for(i=0; i<m; i++)
    {
        scanf("%s", &s);

        if(s[0]=='i'){scanf("%d", &a);insert(t, cnt, a);cnt++;}
        if(s[0]=='p')
        {
            if(cnt>0) print1(t, 0);
            printf("\n");
            if(cnt>0) print2(t, 0);
            printf("\n");
        }
    }
       
    return 0;
   
}
   
void print1(Node *t, int p)
{
    if(t[p].left>=0)print1(t, t[p].left);
    printf(" %d", t[p].key);
    if(t[p].right>=0)print1(t, t[p].right);
}
   
void print2(Node *t, int p)
{
    printf(" %d",t[p].key);
    if(t[p].left>=0)printf(t,t[p].left);
    if(t[p].right>=0)printf(t,t[p].right);
}
   
void insert(Node *t, int count, int z)
{
    int x=0, y;
    if(cnt<1) x=-1;
   
    t[cnt].key = z;
    t[cnt].left = -1;
    t[cnt].right= -1;
   
    while(x>=0){
        y = x; 
        if(z < t[x].key)
            x = t[x].left; 
        else
            x = t[x].right; 
    }
   
    if(count<1){}
    else if(z < t[y].key)
    {
        t[y].left = cnt; 
    }
    else {
        t[y].right = cnt;
    }
}

Compiler output:
main.c: In function 'print2':
main.c:55:28: error: passing argument 1 of 'printf' from incompatible pointer type [-Wincompatible-pointer-types]
   55 |     if(t[p].left>=0)printf(t,t[p].left);
      |                            ^
      |                            |
      |                            Node *
In file included from main.c:1:
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'Node *'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.c:56:29: error: passing argument 1 of 'printf' from incompatible pointer type [-Wincompatible-pointer-types]
   56 |     if(t[p].right>=0)printf(t,t[p].right);
      |                             ^
      |                             |
      |                             Node *
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'Node *'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.c: In function 'insert':
main.c:62:8: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
   62 |     if(cnt<1) x=-1;
      |        ^~~
      |        int
main.c:62:8: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<cstdio>
#include<vector>
#include<cstdlib>
#include<iostream>
using namespace std;
struct Node{
Node *parent,*left,*right;
int key;
};
Node *NIL,*root;
void prin_in(Node* node){
    if(node==NIL)return;
    prin_in(node->left);
    printf(" %d",node->key);
    prin_in(node->right);
}
void prin_pre(Node* node){
    if(node==NIL)return;
    printf(" %d",node->key);
    prin_pre(node->left);
    prin_pre(node->right);

}
void insert(int key)
{
    Node *y=NIL;
    Node *x=root;
    Node *z;
    z=(Node*)malloc(sizeof(Node));
    z->key=key;
    z->left=NIL;
    z->right=NIL;
    while(x!=NIL){
        y=x;
        if(z->key<x->key)
           x=x->left;
        else
            x=x->right;
    }
    z->parent=y;
    if(y==NIL){
        root=z;
    } else{
            if(z->key<y->key)
                y->left=z;
            else {
                y->right=z;
            }
    }
}
int main(){
   int n,i,x;
   string s;
   scanf("%d",&n);
   for(int i=0;i<n;i++)
   {
       cin>>s;
       if(s[0]=='i'){
        scanf("%d",&x);
        insert(x);
       }else if(s[0]=='p'){
       prin_in(root);
       printf("\n");
       prin_pre(root);
       printf("\n");
       }
   }
   return 0;
}

Compiler output:
main.c:1:9: fatal error: cstdio: No such file or directory
    1 | #include<cstdio>
      |         ^~~~~~~~
compilation terminated.
Language: C

#include<cstdio>
#define MAXN 500000
struct node {
	int key;
	node *ch[2];
};
node tree[MAXN+5];
node *Root,*NIL,*ncnt;
bool first=true;
void Init() {
	NIL=&tree[0];
	NIL->ch[0]=NIL->ch[1]=NIL;
	ncnt=&tree[1];
	Root=NIL;
}
inline node *NewNode(int val) {
	node *p=++ncnt;
	p->key=val;
	p->ch[0]=p->ch[1]=NIL;
	return p;
}
void Insert(node *&rt,int val) {
	if(rt==NIL) {
		rt=NewNode(val);
		return;
	}
	int d=(val>=rt->key);
	Insert(rt->ch[d],val);
}
void InOrder(node *rt) {
	if(rt==NIL) return;
	InOrder(rt->ch[0]);
	printf(" %d",rt->key);
	InOrder(rt->ch[1]);
}
void PreOrder(node *rt) {
	if(rt==NIL) return;
	printf(" %d",rt->key);
	PreOrder(rt->ch[0]);
	PreOrder(rt->ch[1]);
}
int main()
{
	int n,x;
	char op[100];
	Init();
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%s",op);
		if(op[0]=='i') {
			scanf("%d",&x);
			Insert(Root,x);
		}
		else {
			InOrder(Root);
			puts("");
			PreOrder(Root);
			puts("");
		}
	}
	return 0;
}

Compiler output:
main.c:1:9: fatal error: cstdio: No such file or directory
    1 | #include<cstdio>
      |         ^~~~~~~~
compilation terminated.
Language: C

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define rad M_PI/3
#define N 200001
#define Max 10000
#define NTL -1
struct node {
  struct node *right;
  int key;
  struct node *left;
};
typedef struct node * Pointer;
 
Pointer head, tail;

Pointer makenode(int k){
  Pointer x;
 
  x=malloc(sizeof(struct node));
  x->key = k;
  x->left = x->right = tail;
 
  return x;
}
void init(void){
  head=makenode(-1);
  tail=makenode(-1);
  head->right=tail;
  head->left=tail;
}
void preorder(Pointer node){
  if(node != tail){
    printf(" %d", node->key);
    preorder(node->left);
    preorder(node->right);
  }
}
 
void inorder(Pointer node){
  if(node != tail){
    inorder(node->left);
    printf(" %d", node->key);
    inorder(node->right);
  }
}

int main()
{
    char str[7];
  int n,k;
 
  init();
  scanf("%d" ,&n);
  while(n--){
    scanf("%s" ,str);
 
    if(str[0] == 'i'){
      scanf("%d" ,&k);
      insert(k, head);
    }else{
      inorder(head->right);
      printf("\n");
      preorder(head->right);
      printf("\n");
    }
  }
 
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:61:7: error: implicit declaration of function 'insert' [-Wimplicit-function-declaration]
   61 |       insert(k, head);
      |       ^~~~~~
Language: C

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define rad M_PI/3
#define N 200001
#define Max 10000
#define NTL -1
struct node {
  struct node *right;
  int key;
  struct node *left;
};
typedef struct node * Pointer;
 
Pointer head, tail;

Pointer makenode(int k){
  Pointer x;
 
  x=malloc(sizeof(struct node));
  x->key = k;
  x->left = x->right = tail;
 
  return x;
}
void insert(int k, NodePointer p){
  if(k < p->key){
    if(p->left == tail){
      p->left = makenode(k);
    }else{
      insert(k , p->left);
    }
  }else{
    if(p->right == tail){
      p->right = makenode(k);
    }else{
      insert(k , p->right);
    }
  }
}
void init(void){
  head=makenode(-1);
  tail=makenode(-1);
  head->right=tail;
  head->left=tail;
}
void preorder(Pointer node){
  if(node != tail){
    printf(" %d", node->key);
    preorder(node->left);
    preorder(node->right);
  }
}
 
void inorder(Pointer node){
  if(node != tail){
    inorder(node->left);
    printf(" %d", node->key);
    inorder(node->right);
  }
}

int main()
{
    char str[7];
  int n,k;
 
  init();
  scanf("%d" ,&n);
  while(n--){
    scanf("%s" ,str);
 
    if(str[0] == 'i'){
      scanf("%d" ,&k);
      insert(k, head);
    }else{
      inorder(head->right);
      printf("\n");
      preorder(head->right);
      printf("\n");
    }
  }
 
  return 0;
}


Compiler output:
main.c:27:20: error: unknown type name 'NodePointer'; did you mean 'Pointer'?
   27 | void insert(int k, NodePointer p){
      |                    ^~~~~~~~~~~
      |                    Pointer
main.c: In function 'main':
main.c:76:7: error: implicit declaration of function 'insert' [-Wimplicit-function-declaration]
   76 |       insert(k, head);
      |       ^~~~~~
Language: C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>

struct node {
  struct node *right;
  struct node *left;
  int val;
};

typedef struct node Node;

Node *root;
Node *leftMost;
int min = INT_MAX;

void insert(Node *cur, int curVal) {
  if (cur->val == -1) {
    cur->val = curVal;
    if (curVal < min) {
      min = curVal;
      leftMost = cur;
    }
  }
  else if (curVal < cur->val) {
    if(cur->left == NULL) {
      Node *new = malloc(sizeof(Node));
      new->val = -1;
      new->left = NULL;
      new->right = NULL;
      //      printf("allocated a node\n");
      cur->left = new;
    }
    insert(cur->left, curVal);
  } else {
    if(cur->right == NULL) {
      Node *new = malloc(sizeof(Node));
      new->val = -1;
      new->left = NULL;
      new->right = NULL;
      //printf("allocated a node\n");
      cur->right = new;
    }
    insert(cur->right, curVal);
  }
    insert(cur->right, curVal);
  }
}

void inorder(Node *cur){
  if (cur == NULL)
    return;

  inorder(cur->left);
  if (cur == leftMost)
    printf("%d", cur->val);
  else
    printf(" %d", cur->val);
  inorder(cur->right);
}

void preorder(Node *cur){
  if (cur == NULL)
    return;

  if (cur == root)
    printf("%d", cur->val);
  else
    printf(" %d", cur->val);
  preorder(cur->left);
  preorder(cur->right);
}

int main() {
  int commands, i, num;
  char com[20];

  root = malloc(sizeof(Node));
  root->val = -1;
  root->left = NULL;
  root->right = NULL;

  scanf("%d", &commands);

  for (i = 0; i < commands; i++) {
    scanf("%s", &com);
    if (!strcmp(com, "insert")) {
      scanf("%d", &num);
      insert(root, num);
      //printf("inserted!\n");
    } else if (!strcmp(com, "print")) {
      //printf("inserted!\n");
    } else if (!strcmp(com, "print")) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
}



Compiler output:
main.c:49:1: error: expected identifier or '(' before '}' token
   49 | }
      | ^
Language: C

#include <stdio.h>
#include <stdlib.h>

// 節点の構造体を定義
struct Node {
  int key;
  struct Node *right, *left, *parent;
};

// rootとNILの構造体を初期化
struct Node *root
struct Node *NIL;

void insert(int k) {
  //
  struct Node *y =  NIL;
  struct Node *x = root;
  struct Node *z;

  // insertする節点を初期化
  z = (struct Node *)malloc(sizeof(struct Node));

  // insertする節点のフィールドを初期化
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;
  if (y == NIL) {
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void preParse(struct Node *u) {
  if (u == NIL) return;
  preParse(u->left);
  printf(" %d", u->key);
  preParse(u->right);
}

void inParse(struct Node *u) {
  if (u == NIL) return;
  printf(" %d", u->key);
  inParse(u->left);
  inParse(u->right);
}

int main() {

  int n, x;
  char com[10];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s%d", com, &x);
    if (com[0] == 'i') {
      insert(x);
    } else {
      preParse(root);
      printf("\n");
      inParse(root);
      printf("\n");
    }
  }
  return 0;
}



Compiler output:
main.c:11:18: error: expected ';' before 'struct'
   11 | struct Node *root
      |                  ^
      |                  ;
   12 | struct Node *NIL;
      | ~~~~~~            
main.c: In function 'insert':
main.c:17:20: error: 'root' undeclared (first use in this function)
   17 |   struct Node *x = root;
      |                    ^~~~
main.c:17:20: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'main':
main.c:72:16: error: 'root' undeclared (first use in this function)
   72 |       preParse(root);
      |                ^~~~
Language: C

#include <stdio.h>
#include <stdlib.h>

struct node{

int id;
struct node* parentNode;
struct node* leftChild;
struct node* rightChild;

}

void insert(struct node*);
void printNodes(void);

struct node* nodes[100];

main(){

int n, i, id;
char command[7];

scanf("%d",&n);

for(i=0; i<n; i++){

scnaf("%s",command);
if(command[0]=='i'){
scanf("%d",&id);
insert(id);
}else if(command[0]=='p'){
printNodes();
}

}/* END OF LOOP */

}

void insert(struct node* nd){



}

struct node* create(int id){



}

int searchNode(int id){

}

void printNodes(struct node* nd){



}

void preOrder(struct node* nd){

}

void inOrder(struct node* nd){

}

Compiler output:
main.c:13:1: error: expected ';', identifier or '(' before 'void'
   13 | void insert(struct node*);
      | ^~~~
main.c:18:1: error: return type defaults to 'int' [-Wimplicit-int]
   18 | main(){
      | ^~~~
main.c: In function 'main':
main.c:27:1: error: implicit declaration of function 'scnaf'; did you mean 'scanf'? [-Wimplicit-function-declaration]
   27 | scnaf("%s",command);
      | ^~~~~
      | scanf
main.c:30:8: error: passing argument 1 of 'insert' makes pointer from integer without a cast [-Wint-conversion]
   30 | insert(id);
      |        ^~
      |        |
      |        int
main.c:13:13: note: expected 'struct node *' but argument is of type 'int'
   13 | void insert(struct node*);
      |             ^~~~~~~~~~~~
main.c: At top level:
main.c:55:6: error: conflicting types for 'printNodes'; have 'void(struct node *)'
   55 | void printNodes(struct node* nd){
      |      ^~~~~~~~~~
main.c:14:6: note: previous declaration of 'printNodes' with type 'void(void)'
   14 | void printNodes(void);
      |      ^~~~~~~~~~