Does not name a type
Don't know why compiler is giving "'nodes' does not name a type" error.
struct node;
struct node{
int data;
struct node* left;
struct node* right;
};
struct node *nodes[1024];
nodes[1]->data = 1;
nodes[1]->left = NULL;
nodes[1]->right = NULL;
Solution 1:
Now I'm assuming you wrote the code exactly as specified:
struct node *nodes[1024];
nodes[1]->data = 1;
nodes[1]->left = NULL;
nodes[1]->right = NULL;
The reason you are getting compiler errors is because that is not valid C++ code.
But if you move that code into a function it will compile just fine:
struct node *nodes[1024];
void AddFunction()
{
nodes[1]->data = 1;
nodes[1]->left = NULL;
nodes[1]->right = NULL;
}