I am just trying to set up a simple recursive struct without too much knowledge of C (have to learn somehow)
here is my make compile line
g++ -o cs533_hw3 main.c
here is my code
typedef struct Node Node;
struct Node
{
int texture;
float rotation;
Node *children[2];
};
Node rootNode;
rootNode.rotation
Here is my error on the last line
error: 'rootNode' does not name a type
Code has to be in functions in C. You can declare variables at the global scope, but you can't put statements there.
Corrected example:
typedef struct Node Node;
struct Node
{
int texture;
float rotation;
Node *children[2];
};
Node rootNode;
int main(void)
{
rootNode.rotation = 12.0f;
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With