that means the order is immaterial.
the sizeof the struct always remains same irrespective of the order and just
depends on the type of variables???
why char with double does not get size in multiples of 8??

On Sat, Aug 6, 2011 at 12:54 PM, Puneet Gautam <puneet.nsi...@gmail.com>wrote:

> Sorry guys, int is 4 bytes on 64 bit and 2 bytes on 32 bit system..
>
> But padding rule remains same for both structures as mentioned above...
>
>
>
>
> On 8/6/11, Puneet Gautam <puneet.nsi...@gmail.com> wrote:
> > There is no difference between the two...
> >
> > On 32 bit system, both structures need every address location where
> > int and pointer are stored to be a multiple of 4(highest size is 4)..
> >
> > On 64 bit,
> > even if pointer is 4bytes(say, in 64 bit system), and p1, p2 be
> > structure variables, then p2 should start at address which is multiple
> > of 8 as int data is 8bytes. So, if p1 starts at 0, it should end at 16
> > not 12 so that p2 starts at 8's multiple.
> >
> > This is done by padding pointer by 4bytes in both I and II struct.
> > declarations.
> >
> >
> > Hope i made it clear...!
> >
> > Thanks.
> >
> >
> >
> >
> > On 8/6/11, Tushar Bindal <tushicom...@gmail.com> wrote:
> >>
> http://www.serc.iisc.ernet.in/ComputingFacilities/systems/cluster/xlf/html/xlfug/ug35.htm
> >> this says int is always 4 bytes and pointer is 8 bytes on 64 bit
> >> compiler.
> >>
> >> so how does padding affect these structures because of the difference in
> >> size of int and pointer?
> >>
> >>
> >> I tried this program
> >> https://ideone.com/CRU6x#view_edit_box
> >> char always gets 4 bytes whenever it has int or double in the same
> struct
> >> irrrespctive of the order of the declaration of variables.
> >> I thought char should get size 8 when there is a double in the ame
> struct
> >> whereas it gets size 4 only.
> >> what is the problem here?
> >>
> >> On Sat, Aug 6, 2011 at 4:40 AM, Shashank Jain <shashan...@gmail.com>
> >> wrote:
> >>
> >>> i dont understand the diff btw dem, could u plz elaborate?
> >>>
> >>> Shashank Jain
> >>> IIIrd year
> >>> Computer Engineering
> >>> Delhi College of Engineering
> >>>
> >>>
> >>>
> >>> On Sat, Aug 6, 2011 at 12:32 AM, Kamakshii Aggarwal
> >>> <kamakshi...@gmail.com
> >>> > wrote:
> >>>
> >>>> in case of 64 bit,
> >>>> size of second structure will also be 16 not 8
> >>>>
> >>>>
> >>>> On Fri, Aug 5, 2011 at 11:40 PM, UTKARSH SRIVASTAV <
> >>>> usrivastav...@gmail.com> wrote:
> >>>>
> >>>>> I think voth are just same..................
> >>>>>
> >>>>>
> >>>>> On Fri, Aug 5, 2011 at 10:57 AM, priya v <pria....@gmail.com> wrote:
> >>>>>
> >>>>>> in case of 64 bit machine y doesn't padding happen in the 2nd
> >>>>>> structure?
> >>>>>>
> >>>>>>
> >>>>>> On Fri, Aug 5, 2011 at 11:21 PM, hary rathor
> >>>>>> <harry.rat...@gmail.com>wrote:
> >>>>>>
> >>>>>>> no ,if u r using 32 bit machine . that will use 4 byte pointer size
> >>>>>>> ,
> >>>>>>> but   in 64 machine that enforce to be size of 8 . where padding
> >>>>>>> will
> >>>>>>> take int your given first structure
> >>>>>>>
> >>>>>>> so for 32 bit- size will 8 8 for both structure
> >>>>>>> for 64 bit - size will 16 and 12 respectively cause of 4 bit
> padding
> >>>>>>> in
> >>>>>>> one structure
> >>>>>>>
> >>>>>>> hence 2nd structure is good for use
> >>>>>>>
> >>>>>>> --
> >>>>>>> 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.
> >>>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>> --
> >>>>> *UTKARSH SRIVASTAV
> >>>>> CSE-3
> >>>>> B-Tech 2nd Year
> >>>>> @MNNIT ALLAHABAD*
> >>>>>
> >>>>>
> >>>>>  --
> >>>>> 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.
> >>>>>
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>> Regards,
> >>>> Kamakshi
> >>>> kamakshi...@gmail.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.
> >>>>
> >>>
> >>>  --
> >>> 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.
> >>
> >>
> >
>
> --
> 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.

Reply via email to