F
Fernando Barsoba
Hi all,
I have a simple question regarding dynamic memory allocation.. is there
a way to create a variable for which we don't know its size using the
'stack' instead of the 'heap'? For instance, I have the following:
But what if I don't know beforehand the size of MESG_LENGTH? Can I have
#define a variable taking its value from outside the code? for instance,
from a file or a parameter?
I know that for these situations one usually uses the 'heap' (malloc,
etc).. but I was wondering if there is a way to do it as asked... just
curiosity..
Thanks,
FBM
I have a simple question regarding dynamic memory allocation.. is there
a way to create a variable for which we don't know its size using the
'stack' instead of the 'heap'? For instance, I have the following:
> #define MESG_LENGTH 12
> unsigned char packet[sizeof(struct ip) + MESG_LENGTH];
But what if I don't know beforehand the size of MESG_LENGTH? Can I have
#define a variable taking its value from outside the code? for instance,
from a file or a parameter?
I know that for these situations one usually uses the 'heap' (malloc,
etc).. but I was wondering if there is a way to do it as asked... just
curiosity..
Thanks,
FBM