Language: C++

#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  int key;
  Node *right,*left,*parent;
};

Node *root, *NIL;

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

  z = (Node *)malloc(sizeof(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);
  preorder(u.left);
  preorder(u.right);
}

int main(){
  int n,i,x;
  string com;

  scanf("%d",&n);

  for(i = 0;i < n; i++){
    cin >> com;
    if(com == "insert"){
      scanf("%d",&x);
      insert(x);
    }else if(com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Compiler output:
a.cc: In function 'void insert(int)':
a.cc:20:5: error: request for member 'key' in 'z', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   20 |   z.key = k;
      |     ^~~
a.cc:21:5: error: request for member 'left' in 'z', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   21 |   z.left = NIL;
      |     ^~~~
a.cc:22:5: error: request for member 'right' in 'z', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   22 |   z.right = NIL;
      |     ^~~~~
a.cc:26:10: error: request for member 'key' in 'z', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   26 |     if(z.key < x.key){
      |          ^~~
a.cc:26:18: error: request for member 'key' in 'x', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   26 |     if(z.key < x.key){
      |                  ^~~
a.cc:27:13: error: request for member 'left' in 'x', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   27 |       x = x.left;
      |             ^~~~
a.cc:29:13: error: request for member 'right' in 'x', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   29 |       x = x.right;
      |             ^~~~~
a.cc:32:5: error: request for member 'parent' in 'z', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   32 |   z.parent = y;
      |     ^~~~~~
a.cc:36:10: error: request for member 'key' in 'z', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   36 |     if(z.key < y.key){
      |          ^~~
a.cc:36:18: error: request for member 'key' in 'y', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   36 |     if(z.key < y.key){
      |                  ^~~
a.cc:37:9: error: request for member 'left' in 'y', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   37 |       y.left = z;
      |         ^~~~
a.cc:39:9: error: request for member 'right' in 'y', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   39 |       y.right = z;
      |         ^~~~~
a.cc: In function 'void inorder(Node*)':
a.cc:46:13: error: request for member 'left' in 'u', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   46 |   inorder(u.left);
      |             ^~~~
a.cc:47:18: error: request for member 'key' in 'u', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   47 |   printf(" %d",u.key);
      |                  ^~~
a.cc:48:13: error: request for member 'right' in 'u', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   48 |   inorder(u.right);
      |             ^~~~~
a.cc: In function 'void preorder(Node*)':
a.cc:53:18: error: request for member 'key' in 'u', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   53 |   printf(" %d",u.key);
      |                  ^~~
a.cc:54:14: error: request for member 'left' in 'u', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   54 |   preorder(u.left);
      |              ^~~~
a.cc:55:14: error: request for member 'right' in 'u', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
   55 |   preorder(u.right);
      |              ^~~~~