struct abc{
char ch;
};
printf(“%d”,sizeof(abc));//prints 1 byte but
struct abc
{
int i;
struct a{
char ch;
};
}abc;
printf(“%d”,sizeof(abc));//prints only 4 bytes
but if we define the variable for struct a then it
prints the size along with the size of ch.
We want to ask if the structure is single then evem
if variable is not defined it shows the sizeof struct
but in nested structure it doesnt show sizeof that
struct whose variable is not defined.why??
struct a will not come into existence until its variable gets declared even when it is within another struct..
it is as good as writing “int ;”
(this will surely give a warning)
there is no significance untill you declare a variable for the inner structure. thats why it gives warning that “declaration does not declare anything”.