Language: C

#include <stdio.h>

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

void insert(Node*, Node*);
void print_M(Node*);
void print_P(Node*);


Node T[500000];

int main()
{
  int m,k,i;
  char enter[6];
  Node z;
  Node *p;

  T[0].key = -1;
  T[0].left = NULL;
  T[0].right = NULL;
  T[0].p = NULL;

  scanf("%d",&m);
  for(i = 0;i < m;i++){
    scanf("%s %d",enter,&k);
    if(strcmp(enter,"insert") == 0){
      z.key = k;
      z.left = NULL;
      z.right = NULL;
      z.p = NULL;
      insert(T[0],&z);
    }
    else {
      print_M(T[0]);
      print_P(T[0]);
    }

    return 0;
}

void insert(Node T, Node *z)
{
  Node x,y;

  y = NULL; //xの親
  x = T[0]; //Tの根
  while(x != NULL){
    y = x; //親を設定
    if(z.key < x.key) x = x.left; //左の子へ移動
    else x = x.right; //右の子へ移動
  }

  z.p = y;

  if(y == NULL) tree_root = z; //Tが空の場合
  else if(z.key < y.key) y.left = z; //zをyの左の子にする
  else y.right = z; //zをyの右の子にする
}

void print_M(Node now)
{
  if(now.left->key != -1) print_M(now.left->key);
  print_M(now.p->key);
  if(now.right-> != -1) print_P(now.right->key);
}
   
void print_P(Node now)
{
  print_M(now.p->key);
  if(now.left->key != -1) print_M(now.left->key);
  if(now.right->key != NULL) print_P(now.right->key);
}

Compiler output:
main.c: In function 'main':
main.c:32:8: error: implicit declaration of function 'strcmp' [-Wimplicit-function-declaration]
   32 |     if(strcmp(enter,"insert") == 0){
      |        ^~~~~~
main.c:2:1: note: include '<string.h>' or provide a declaration of 'strcmp'
    1 | #include <stdio.h>
  +++ |+#include <string.h>
    2 | 
main.c:37:15: error: incompatible type for argument 1 of 'insert'
   37 |       insert(T[0],&z);
      |              ~^~~
      |               |
      |               Node {aka struct node}
main.c:10:13: note: expected 'Node *' {aka 'struct node *'} but argument is of type 'Node' {aka 'struct node'}
   10 | void insert(Node*, Node*);
      |             ^~~~~
main.c:40:16: error: incompatible type for argument 1 of 'print_M'
   40 |       print_M(T[0]);
      |               ~^~~
      |                |
      |                Node {aka struct node}
main.c:11:14: note: expected 'Node *' {aka 'struct node *'} but argument is of type 'Node' {aka 'struct node'}
   11 | void print_M(Node*);
      |              ^~~~~
main.c:41:16: error: incompatible type for argument 1 of 'print_P'
   41 |       print_P(T[0]);
      |               ~^~~
      |                |
      |                Node {aka struct node}
main.c:12:14: note: expected 'Node *' {aka 'struct node *'} but argument is of type 'Node' {aka 'struct node'}
   12 | void print_P(Node*);
      |              ^~~~~
In file included from /usr/include/stdio.h:34,
                 from main.c:1:
main.c: In function 'insert':
main.c:51:7: error: incompatible types when assigning to type 'Node' {aka 'struct node'} from type 'void *'
   51 |   y = NULL; //xの親
      |       ^~~~
main.c:52:8: error: subscripted value is neither array nor pointer nor vector
   52 |   x = T[0]; //Tの根
      |        ^
main.c:53:11: error: invalid operands to binary != (have 'Node' {aka 'struct node'} and 'void *')
   53 |   while(x != NULL){
      |           ^~
main.c:55:9: error: 'z' is a pointer; did you mean to use '->'?
   55 |     if(z.key < x.key) x = x.left; //左の子へ移動
      |         ^
      |         ->
main.c:55:27: error: incompatible types when assigning to type 'Node' {aka 'struct node'} from type 'struct node *'
   55 |     if(z.key < x.key) x = x.left; //左の子へ移動
      |                           ^
main.c:56:14: error: incompatible types when assigning to type 'Node' {aka 'struct node'} from type 'struct node *'
   56 |     else x = x.right; //右の子へ移動
      |              ^
main.c:59:4: error: 'z' is a pointer; did you mean to use '->'?
   59 |   z.p = y;
      |    ^
      |    ->
main.c:61:8: error: invalid operands to binary == (have 'Node' {aka 'struct node'} and 'void *')
   61 |   if(y == NULL) tree_root = z; //Tが空の場合
      |        ^~
main.c:61:17: error: 'tree_root' undeclared (first use in this function)
   61 |   if(y == NULL) tree_root = z; //Tが空の場合
      |                 ^~~~~~~~~
main.c:61:17: note: each undeclared identifier is reported only once for each function it appears in
main.c:62:12: error: 'z' is a pointer; did you mean to use '->'?
   62 |   else if(z.key < y.key) y.left = z; //zをyの左の子にする
      |            ^
      |            ->
main.c: In function 'print_M':
main.c:68:43: error: incompatible type for argument 1 of 'print_M'
   68 |   if(now.left->key != -1) print_M(now.left->key);
      |                                   ~~~~~~~~^~~~~
      |                                           |
      |                                           int
main.c:66:19: note: expected 'Node' {aka 'struct node'} but argument is of type 'int'
   66 | void print_M(Node now)
      |              ~~~~~^~~
main.c:69:16: error: incompatible type for argument 1 of 'print_M'
   69 |   print_M(now.p->key);
      |           ~~~~~^~~~~
      |                |
      |                int
main.c:66:19: note: expected 'Node' {aka 'struct node'} but argument is of type 'int'
   66 | void print_M(Node now)
      |              ~~~~~^~~
main.c:70:18: error: expected identifier before '!=' token
   70 |   if(now.right-> != -1) print_P(now.right->key);
      |                  ^~
main.c:70:42: error: passing argument 1 of 'print_P' makes pointer from integer without a cast [-Wint-conversion]
   70 |   if(now.right-> != -1) print_P(now.right->key);
      |                                 ~~~~~~~~~^~~~~
      |                                          |
      |                                          int
main.c:12:14: note: expected 'Node *' {aka 'struct node *'} but argument is of type 'int'
   12 | void print_P(Node*);
      |              ^~~~~
main.c: In function 'print_P':
main.c:75:16: error: incompatible type for argument 1 of 'print_M'
   75 |   print_M(now.p->key);
      |           ~~~~~^~~~~
      |                |
      |                int
main.c:66:19: note: expected 'Node' {aka 'struct node'} but argument is of type 'int'
   66 | void print_M(Node now)
      |              ~~~~~^~~
main.c:76:43: error: incompatible type for argument 1 of 'print_M'
   76 |   if(now.left->key != -1) print_M(now.left->key);
      |                                   ~~~~~~~~^~~~~
      |                                           |
      |                                           int
main.c:66:19: note: expected 'Node' {aka 'struct node'} but argument is of type 'int'
   66 | void print_M(Node now)
      |              ~~~~~^~~
main.c:77:21: warning: comparison between pointer and integer
   77 |   if(now.right->key != NULL) print_P(now.right->key);
      |                     ^~
main.c:77:47: error: incompatible type for argument 1 of 'print_P'
   77 |   if(now.right->key != NULL) print_P(now.right->key);
      |                                      ~~~~~~~~~^~~~~
      |                                               |
      |                                               int
main.c:73:19: note: expected 'Node' {aka 'struct node'} but argument is of type 'int'
   73 | void print_P(Node now)
      |              ~~~~~^~~
main.c: In function 'main':
main.c:78:1: error: expected declaration or statement at end of input
   78 | }
      | ^