behavior of sizeof operator?
#include<stdio.h>
struct krishna {
int i,j,k,l,m;
char c;
double d;
char g[48];
};
int main() {
struct krishna *me={0};
printf("%ld %ld\n",sizeof(me),sizeof(*me));//output is 8 80 how??
return 0;
}
Hello everyone I am new here and the compiler I use is gcc compiler in the
above code can anyone explain why
1) pointer irrespective of any type is allocated 8 ?
2) sizeof the above struct is 80 ? Can anyone explain to me in general for
any structure how can one determine the structure size , I am getting
confused each time I expect one value but getting a different answer and I
have also read other questions and answers in stack overflow regarding
this and I am still not getting it.Please help.
No comments:
Post a Comment