Wednesday, January 31, 2007

 

sizeof my_what or sizeof (my_what)

sizeof is an operator, like ++ and *, and not a function.

To get the size of a structure, use (). To get the size of a variable, don't use ().

struct st_s{
int i, j;
} s;

int sz;
sz = sizeof(struct st_s);
sz = sizeof s;
sz = sizeof (s); /* misused, but gcc and probably most compiler will accept this */

Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?