Re: [algogeeks] Re: size of self referential structure
for compiler giving 8 bit for pointers, shouldn't int also be of 8 bits?? On Thu, Jul 28, 2011 at 12:26 PM, Jnana Sagar wrote: > @aditya..the answer may vary, because c is machine dependent > language..in few machines int is of 2 bytes and char is of 1 byte..u > can't say..it varies with diff machines > > On 7/26/11, aditya kumar wrote: > > char *s[5] is a array of pointers of type char . but the thing is size of > > pointers is 4byte irrespective of its type . coz address is always an > > unsigned int which is of 4byte. > > On Tue, Jul 26, 2011 at 7:11 PM, Puneet Gautam > > 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 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 wrote: > >> >> #include > >> >> #include > >> >> 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. > > -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.com -- 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.
Re: [algogeeks] Re: size of self referential structure
@aditya..the answer may vary, because c is machine dependent language..in few machines int is of 2 bytes and char is of 1 byte..u can't say..it varies with diff machines On 7/26/11, aditya kumar wrote: > char *s[5] is a array of pointers of type char . but the thing is size of > pointers is 4byte irrespective of its type . coz address is always an > unsigned int which is of 4byte. > On Tue, Jul 26, 2011 at 7:11 PM, Puneet Gautam > 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 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 wrote: >> >> #include >> >> #include >> >> 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.
Re: Re : [algogeeks] Re: size of self referential structure
Okay. I was a bit wrongactually the thing is that The exact number of bytes allocated for various C data types depends on *both the machine and the compiler.** *so it may be the that the compiler u are using is 32 bit.. one thing that u can try out is that on ubuntu install 64 bit codeblocks ide. i think u will get size of pointers as 8 bytes. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.
Re: Re : [algogeeks] Re: size of self referential structure
@ sunny ; i am working on 64 bit windows 7 with dev and also in gcc + ubuntu 64 bit ... am using i3 processor that is 64 bit... what should do to get size 8 byte ? -- 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.
Re: Re : [algogeeks] Re: size of self referential structure
On Wed, Jul 27, 2011 at 2:18 PM, hary rathor wrote: > @sunny : what you means by machine dependent means 64 bit: you means by > compiler / operating system /computer architecture ? > because i never get size of pointer 8 byte. if your statement true then > tell me which compiler / operating system /computer architecture i should > have get this output 8. > > A 64 bit machine running a 64 bit OS, on which using a compiler targeted for 64 bit executable will give you pointer size of 8. -- -- 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.
Re: Re : [algogeeks] Re: size of self referential structure
computer architecture !!! 64 bit machine has word size of 8 bytes so pointers are of 8 bytes you never got size as 8 byte because u might be working on a 32 bit machine !! On Wed, Jul 27, 2011 at 2:18 PM, hary rathor wrote: > @sunny : what you means by machine dependent means 64 bit: you means by > compiler / operating system /computer architecture ? > because i never get size of pointer 8 byte. if your statement true then > tell me which compiler / operating system /computer architecture i should > have get this output 8. > > > -- > 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. > -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.
Re: Re : [algogeeks] Re: size of self referential structure
@sunny : what you means by machine dependent means 64 bit: you means by compiler / operating system /computer architecture ? because i never get size of pointer 8 byte. if your statement true then tell me which compiler / operating system /computer architecture i should have get this output 8. -- 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.
Re: Re : [algogeeks] Re: size of self referential structure
yes on a 64 bit machine ans will be 4+5*8+8 = 52 bytes pointers take 8 byte on 64 bit machine On Tue, Jul 26, 2011 at 8:00 PM, vaibhav shukla wrote: > will there be any difference in size on 32 machine and on 64 bit machine ? > how and what ? > > On Tue, Jul 26, 2011 at 7:58 PM, kavitha nk wrote: > >> >> >> sry frendzma above posts were wrongans is 28 if ptr takes 4 >> bytes... >> //BE COOL// kavi >> >> -- >> 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. >> > > > > -- > best wishes!! > Vaibhav > > > -- > 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. > -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.
Re: Re : [algogeeks] Re: size of self referential structure
will there be any difference in size on 32 machine and on 64 bit machine ? how and what ? On Tue, Jul 26, 2011 at 7:58 PM, kavitha nk wrote: > > > sry frendzma above posts were wrongans is 28 if ptr takes 4 > bytes... > //BE COOL// kavi > > -- > 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. > -- best wishes!! Vaibhav -- 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.
Re: Re : [algogeeks] Re: size of self referential structure
sry frendzma above posts were wrongans is 28 if ptr takes 4 bytes... //BE COOL// kavi -- 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.
Re : [algogeeks] Re: size of self referential structure
> On Tue, Jul 26, 2011 at 7:11 PM, Puneet Gautam > wrote: > >> @everyone: >> I have this mind strangling doubt..!!! >> >> Why is "char *s[5]" of 20 bytes...? >> 5 x sizeof (*s). do you see ? -- 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.
Re : [algogeeks] Re: size of self referential structure
It is not 28 ? 4 sizeof(int) + 20 + 4 (ptr). And no padding, cos' all is mutiple of 4. >> > On Jul 26, 7:40 am, Puneet Gautam wrote: >> >> #include >> >> #include >> >> 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.
Re: [algogeeks] Re: size of self referential structure
sry memory... On 7/26/11, Akshata Sharma wrote: > @kavitha, what is m/y? > > On Tue, Jul 26, 2011 at 7:27 PM, kavitha nk wrote: > >> the link ll not occupy any m/y here...so its output ll be 14(int -4 >> bytes,ptr-2 bytes);;if i'm wrong jst crct it... >> >> >> On 7/26/11, Prem Krishna Chettri wrote: >> > Its Cos that is pointer and all pointers is 4 bytes address.. >> > >> > On Tue, Jul 26, 2011 at 7:11 PM, Puneet Gautam >> > 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 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 wrote: >> >> >> #include >> >> >> #include >> >> >> 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. >> > >> > >> >> >> -- >> //BE COOL// kavi >> >> -- >> 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. > > -- //BE COOL// kavi -- 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.
Re: [algogeeks] Re: size of self referential structure
@kavitha, what is m/y? On Tue, Jul 26, 2011 at 7:27 PM, kavitha nk wrote: > the link ll not occupy any m/y here...so its output ll be 14(int -4 > bytes,ptr-2 bytes);;if i'm wrong jst crct it... > > > On 7/26/11, Prem Krishna Chettri wrote: > > Its Cos that is pointer and all pointers is 4 bytes address.. > > > > On Tue, Jul 26, 2011 at 7:11 PM, Puneet Gautam > > 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 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 wrote: > >> >> #include > >> >> #include > >> >> 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. > > > > > > > -- > //BE COOL// kavi > > -- > 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.
Re: [algogeeks] Re: size of self referential structure
the link ll not occupy any m/y here...so its output ll be 14(int -4 bytes,ptr-2 bytes);;if i'm wrong jst crct it... On 7/26/11, Prem Krishna Chettri wrote: > Its Cos that is pointer and all pointers is 4 bytes address.. > > On Tue, Jul 26, 2011 at 7:11 PM, Puneet Gautam > 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 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 wrote: >> >> #include >> >> #include >> >> 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. > > -- //BE COOL// kavi -- 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.
Re: [algogeeks] Re: size of self referential structure
padding.. 4 byes int + 3 padding bytes + 5 char bytes + 4 bytes pointer =16 On Tue, Jul 26, 2011 at 7:22 PM, Puneet Gautam wrote: > for the above mentioned code, in previous post,: shudnt the output be > 4+5+4=13? > > On 7/26/11, Prem Krishna Chettri wrote: > > Its Cos that is pointer and all pointers is 4 bytes address.. > > > > On Tue, Jul 26, 2011 at 7:11 PM, Puneet Gautam > > 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 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 wrote: > >> >> #include > >> >> #include > >> >> 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. > > -- 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.
Re: [algogeeks] Re: size of self referential structure
for the above mentioned code, in previous post,: shudnt the output be 4+5+4=13? On 7/26/11, Prem Krishna Chettri wrote: > Its Cos that is pointer and all pointers is 4 bytes address.. > > On Tue, Jul 26, 2011 at 7:11 PM, Puneet Gautam > 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 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 wrote: >> >> #include >> >> #include >> >> 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.
Re: [algogeeks] Re: size of self referential structure
Its Cos that is pointer and all pointers is 4 bytes address.. On Tue, Jul 26, 2011 at 7:11 PM, Puneet Gautam 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 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 wrote: > >> #include > >> #include > >> 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.
Re: [algogeeks] Re: size of self referential structure
ok...! #include #include 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 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 > 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 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 wrote: >> >> #include >> >> #include >> >> 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.
Re: [algogeeks] Re: size of self referential structure
char *s[5] is a array of pointers of type char . but the thing is size of pointers is 4byte irrespective of its type . coz address is always an unsigned int which is of 4byte. On Tue, Jul 26, 2011 at 7:11 PM, Puneet Gautam 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 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 wrote: > >> #include > >> #include > >> 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.
Re: [algogeeks] Re: size of self referential structure
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 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 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 wrote: > >> #include > >> #include > >> 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.
Re: [algogeeks] Re: size of self referential structure
@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 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 wrote: >> #include >> #include >> 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.