Exforsys
+ Reply to Thread
Results 1 to 4 of 4

hi all

This is a discussion on hi all within the C and C++ forums, part of the Programming Talk category; any one pls tell me about structure padding?...

  1. #1
    devsuv is offline Junior Member Array
    Join Date
    Jun 2006
    Answers
    2

    hi all

    any one pls tell me about structure padding?


  2. #2
    blenda is offline Member Array
    Join Date
    May 2006
    Answers
    36
    Hi,
    Struture padding main usage is for handling memory alignment. This concept is particularly useful when in a structure variables of different sizes need to be put together in which case a boundary size is fixed and structure padding applied in this.

    Blenda


  3. #3
    Adrian is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    124
    I have a rough idea about structure padding. It is adding of bits in structure of a C program internally. But I do not have idea about why is this added and how it gets added. I am waiting for someone to clarify this.


  4. #4
    sammy is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    144
    adrian you are right. Structure padding is addition of bits or padding bytes. In C we know that memory is allocated based on data type. That is for integer it is 2 bytes, for long 4 bytes and so on. Since structures are association of different data types to maintain byte boundary padding bytes takes place. This is the reason for structure padding.


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...