Hello.
I was practicing working with structures and wrote out this program:
But the compiler complains about 'Undeclared first use in function main()", when I'm trying to create instances of the tree structure.Code:#include <stdio.h> #include <stdlib.h> struct tree { int size, pos; }; int main() { tree leaf; tree *ptr; malloc(sizeof *ptr); // asterisk indicates get value of leaf.size = 1024; leaf.pos = 1; ptr = &leaf; printf("%d\n", ptr->size, "\n", ptr->pos); free(ptr); getchar(); }
I've gone back over my notes, and can't find what's wrong, in fact the declaration for the leaf instance was taken right from the tutorial.
Am I missing something? I'd be grateful if someone could point me in the right direction for this.
Thanks.
Hussein.