ok...! #include<stdio.h> #include<stddef.h> struct node{ int a; char b[5]; struct node *link; }; main() { int a; a=sizeof(struct node); printf("%d",a); getchar(); return 0; }
why is its output : 16? Sudnt it be 4(int a) +5(char b[5] string) +9(link)= 18..? On 7/26/11, Akshata Sharma <akshatasharm...@gmail.com> wrote: > char *s[5] is an array of 5 char pointers. A pointer is an int, of size 4 > bytes. So, 5*4 = 20 bytes > > On Tue, Jul 26, 2011 at 7:11 PM, Puneet Gautam > <puneet.nsi...@gmail.com>wrote: > >> @everyone: >> I have this mind strangling doubt..!!! >> >> Why is "char *s[5]" of 20 bytes...? >> >> yes the output is 28... >> >> On 7/26/11, Don <dondod...@gmail.com> wrote: >> > A reasonable guess would be 28 bytes. But the size of a structure is >> > implementation dependent, and therefore, some other result could be >> > correct as well. >> > Don >> > >> > On Jul 26, 7:40 am, Puneet Gautam <puneet.nsi...@gmail.com> wrote: >> >> #include<stdio.h> >> >> #include<stddef.h> >> >> struct node{ >> >> int a; >> >> char *b[5]; >> >> struct node *link; >> >> }; >> >> main() >> >> { >> >> int a; >> >> a=sizeof(struct node); >> >> printf("%d",a); >> >> getchar(); >> >> return 0; >> >> } >> >> >> >> Whats the output..? >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups >> > "Algorithm Geeks" group. >> > To post to this group, send email to algogeeks@googlegroups.com. >> > To unsubscribe from this group, send email to >> > algogeeks+unsubscr...@googlegroups.com. >> > For more options, visit this group at >> > http://groups.google.com/group/algogeeks?hl=en. >> > >> > >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.