Hello guys..
I´m trying to do something like the code below ..
struct node{
int a;
char *s;
};
void main()
{
node *x;
int sMAX = 3;
int nodeMAX = 10;
x = (node*)malloc((sizeof(int)+sizeof(char)*sMAX)*nodeMAX);
...
}
in other words I want to alloc dynamically the number of nodes and also the length of s in node struct
I tried a lot of things like:
x = (node*)malloc((sizeof(node)*nodeMAX);
x = (node*)malloc((sizeof(struct node)*nodeMAX);
x = (node*)malloc((sizeof(node)+sizeof(char)*sMAX)*nodeMAX);
and my code do not run
Is it possible to do what I want?
thanks.