daily discovery

Memory dump of new things discovered daily.

Friday, December 30, 2005

Variable size C structures

To make structure in C with run time determined size, make it thusly:
struct foo
{
int bar;
char fu[];
};
Then use it thusly:
struct foo * ptr = malloc(sizeof(foo) + number_of_elements_in_array_fu);

Cheers,
Steve


0 Comments:

Post a Comment

<< Home