Here is another approach.... no need to create any instance of structure.
struct XYZ{
int x;
float y;
char z;
};
int main(){
int sz = (int) (((struct XYZ *)0) + 1);
printf("%d",sz);
return 0;
}
How does it work?
((struct XYZ *)0) + 1 = zero + size of structure
= size of structure