@puneet : no , in this case since 4 bytes will be used for int a and int c and then 1 byte for char b with 3 padded bytes next..it wud be the same here
On Fri, Jul 29, 2011 at 12:11 PM, Puneet Gautam <[email protected]>wrote: > @nikhil: If i declare "Char b" after "int c".., would there be any > difference...? > > On 7/28/11, Nikhil Gupta <[email protected]> wrote: > > Here's another example. > > > > struct example > > { > > int a; > > char b; > > int c; > > } > > > > Now if a variable of type example is declared then > > (considering base address as 2000) > > a gets : 2000 to 2003 > > b gets : 2004 > > c gets : 2005 to 2008 ? NO > > > > It gets 2008 to 2011. The bytes from 2005 to 2007 (3 bytes) are padded in > > this case. > > > > On Thu, Jul 28, 2011 at 12:18 AM, Aman Goyal <[email protected]> > wrote: > > > >> yes this will be the case. > >> > >> > >> On Wed, Jul 27, 2011 at 11:35 PM, Puneet Gautam > >> <[email protected]>wrote: > >> > >>> @nikhil:So what u mean is that if i have: > >>> > >>> struct{ > >>> int a; > >>> char b[5]; > >>> }; > >>> > >>> the size of this struct's node will be 12 not 9.., to make it a > multiple > >>> of 4?? > >>> > >>> > >>> > >>> On 7/26/11, Nikhil Gupta <[email protected]> wrote: > >>> > Padding is not a topic of self referential structure. > >>> > > >>> > Padding means that extra spaces of memory are used by the compiler to > >>> > allocate memory. This is done to have the memory address as a > multiple > >>> of > >>> > the size of the variable. This speeds up the processing of these > >>> variables > >>> > by the compiler. > >>> > > >>> > On Tue, Jul 26, 2011 at 8:09 PM, Puneet Gautam > >>> > <[email protected]>wrote: > >>> > > >>> >> what is meant by padding in self_referenced structure? > >>> >> Is it always necessary? > >>> >> > >>> >> -- > >>> >> You received this message because you are subscribed to the Google > >>> Groups > >>> >> "Algorithm Geeks" group. > >>> >> To post to this group, send email to [email protected]. > >>> >> To unsubscribe from this group, send email to > >>> >> [email protected]. > >>> >> For more options, visit this group at > >>> >> http://groups.google.com/group/algogeeks?hl=en. > >>> >> > >>> >> > >>> > > >>> > > >>> > -- > >>> > Nikhil Gupta > >>> > Senior Co-ordinator, Publicity > >>> > CSI, NSIT Students' Branch > >>> > NSIT, New Delhi, India > >>> > > >>> > -- > >>> > You received this message because you are subscribed to the Google > >>> Groups > >>> > "Algorithm Geeks" group. > >>> > To post to this group, send email to [email protected]. > >>> > To unsubscribe from this group, send email to > >>> > [email protected]. > >>> > 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 [email protected]. > >>> To unsubscribe from this group, send email to > >>> [email protected]. > >>> 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 [email protected]. > >> To unsubscribe from this group, send email to > >> [email protected]. > >> For more options, visit this group at > >> http://groups.google.com/group/algogeeks?hl=en. > >> > > > > > > > > -- > > Nikhil Gupta > > Senior Co-ordinator, Publicity > > CSI, NSIT Students' Branch > > NSIT, New Delhi, India > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Algorithm Geeks" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Arun Vish Graduate Student Department of Computer Science University of Southern California -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
