Variable size C structures
To make structure in C with run time determined size, make it thusly:
struct fooThen use it thusly:
{
int bar;
char fu[];
};
struct foo * ptr = malloc(sizeof(foo) + number_of_elements_in_array_fu);
Cheers,
Steve
Memory dump of new things discovered daily.
To make structure in C with run time determined size, make it thusly:
struct fooThen use it thusly:
{
int bar;
char fu[];
};
struct foo * ptr = malloc(sizeof(foo) + number_of_elements_in_array_fu);
0 Comments:
Post a Comment
<< Home