say I have:
and I want to create an array of TreeNode, how do I do that?Code:typedef struct treeNode { .................. ....................... } TreeNode;
This is a discussion on array of typedef struct within the C Programming forums, part of the General Programming Boards category; say I have: Code: typedef struct treeNode { .................. ....................... } TreeNode; and I want to create an array of ...
say I have:
and I want to create an array of TreeNode, how do I do that?Code:typedef struct treeNode { .................. ....................... } TreeNode;
We'll give you three guesses, first two don't count.
No really. Go to your compiler, and try three things. If you don't get one of them right, then tell us what you tried and we'll go over it.
Can I try ?
Here's a secret: You can do this
You do not need to specify the number of elements in *TreeNode when you declare it, but as with a *char, you need to malloc (and possibly realloc) enough space for it. Multiply by sizeof(*TreeNode).Code:typedef struct treeNode { .................. ....................... } *TreeNode;
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
Typedefing pointers can come back to haunt you later. Avoid it, is my advice.
What is so hard about typing out a lone *?
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^