Language: C++

#include <bits/stdc++.h>
using namespace std;

struct Node{
Node *r, *l, *p;
int key;
};

Node *T;

void insert(int x){

Node *z;
z.p = z.r = z.l = NIL;
z.p = k;
Node *y = NIL;
Node *x = T;

while(x != NIL){
y = x;
if(z->key < x->key){
x = x.l;
}else if(z -> key > x -> key){
x = x.r;
}
}

z.p = y;
if(y == NIL){
z = T;
}else if(y -> key < z -> key){
y.r = z;
}else if(y -> key < z -> key){
y.r = z;
}




}

void pre_print(Node *T){
  if(x == -1) return;
  cout << " " << x;
  pre_print(T.l);
  pre_print(T.r);
}
 
void in_print(Node *T){
  if(x == -1) return;
  in_print(T.l);
  cout << " " << x;
  in_print(T.r);
}



int main(){

int n;
string str;

cin >> n;

for(int i = 0; i < n; i++){
int k;
cin >> str >> k;
if(str == "insert"){
insert(k);
}else if(str == "print"){
in_print(T);
cout << endl;
pre_print(T);
cout << endl;
}
}



}

Compiler output:
a.cc: In function 'void insert(int)':
a.cc:14:3: error: request for member 'p' in 'z', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   14 | z.p = z.r = z.l = NIL;
      |   ^
a.cc:14:9: error: request for member 'r' in 'z', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   14 | z.p = z.r = z.l = NIL;
      |         ^
a.cc:14:15: error: request for member 'l' in 'z', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   14 | z.p = z.r = z.l = NIL;
      |               ^
a.cc:14:19: error: 'NIL' was not declared in this scope
   14 | z.p = z.r = z.l = NIL;
      |                   ^~~
a.cc:15:3: error: request for member 'p' in 'z', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   15 | z.p = k;
      |   ^
a.cc:15:7: error: 'k' was not declared in this scope
   15 | z.p = k;
      |       ^
a.cc:17:7: error: declaration of 'Node* x' shadows a parameter
   17 | Node *x = T;
      |       ^
a.cc:11:17: note: 'int x' previously declared here
   11 | void insert(int x){
      |             ~~~~^
a.cc:22:7: error: request for member 'l' in 'x', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   22 | x = x.l;
      |       ^
a.cc:24:7: error: request for member 'r' in 'x', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   24 | x = x.r;
      |       ^
a.cc:28:3: error: request for member 'p' in 'z', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   28 | z.p = y;
      |   ^
a.cc:32:3: error: request for member 'r' in 'y', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   32 | y.r = z;
      |   ^
a.cc:34:3: error: request for member 'r' in 'y', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   34 | y.r = z;
      |   ^
a.cc: In function 'void pre_print(Node*)':
a.cc:43:6: error: 'x' was not declared in this scope
   43 |   if(x == -1) return;
      |      ^
a.cc:44:18: error: 'x' was not declared in this scope
   44 |   cout << " " << x;
      |                  ^
a.cc:45:15: error: request for member 'l' in 'T', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   45 |   pre_print(T.l);
      |               ^
a.cc:46:15: error: request for member 'r' in 'T', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   46 |   pre_print(T.r);
      |               ^
a.cc: In function 'void in_print(Node*)':
a.cc:50:6: error: 'x' was not declared in this scope
   50 |   if(x == -1) return;
      |      ^
a.cc:51:14: error: request for member 'l' in 'T', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   51 |   in_print(T.l);
      |              ^
a.cc:52:18: error: 'x' was not declared in this scope
   52 |   cout << " " << x;
      |                  ^
a.cc:53:14: error: request for member 'r' in 'T', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   53 |   in_print(T.r);
      |              ^