3

I am writing a program in c which traverse a tree in in-order, pre-order and post-order . this code is not compiling properly . it shows a error saying "unknown type name 'node'"

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


struct node* root;

struct node* insert(struct node* r, int data);
void inOrder(struct node* r);
void preOrder(struct node* r);
void postOrder(struct node* r);

what i am missing ?

2
  • 2
    node* left; --> struct node* left;, same for right Commented Oct 20, 2015 at 7:29
  • Alternatively typedef struct node { .. struct node* left; ...} node_t. Commented Oct 20, 2015 at 8:52

1 Answer 1

4

change inside structure

struct node
     {
         int value;
         struct  node* left; //Changed
         struct  node* right;
     };
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.