Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

struct and pointer not working properly in c

Tags:

c

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 ?

like image 271
avijit bhattacharjee Avatar asked Mar 16 '26 09:03

avijit bhattacharjee


1 Answers

change inside structure

struct node
     {
         int value;
         struct  node* left; //Changed
         struct  node* right;
     };
like image 159
Mohan Avatar answered Mar 19 '26 00:03

Mohan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!