i wrote a simple struct
it says i got syntax error
i cant se my error here
??
Code:typedef struct node{
node *left;
node *right;
int data;
}node;
Printable View
i wrote a simple struct
it says i got syntax error
i cant se my error here
??
Code:typedef struct node{
node *left;
node *right;
int data;
}node;
do you want the same name for the struct tag and its alias?
We've done this before. The name "node" does not exist until you get to the actual typedef at the bottom line. Until then you must use the actual name of the type, "struct node".
Yes, because node was not declared until after the struct was defined. Here are two solutions:
Code:typedef struct node {
struct node *left;
struct node *right;
int data;
} node;
Code:typedef struct node node;
struct node {
node *left;
node *right;
int data;
};
this is a combination of struct and typedef
instead writing struct node each time.
using this code i can write only "node"
which i wrote in the end.
That's maybe two direction link list
This is my first post!
I‘'m from China and my English is bad……
Do you understand what I say??
its HE
:)