What is structure padding & expalain wid example
what is bit wise structure?



What is structure padding & expalain wid example what is bit wise structure?..

Answer / pankaj saraf

Padding is actually a compiler optimization technique, which
fill up the area between to member to make multiples of 4
bytes (32 bits). Only combination chars/ shorts int/ both ca
e able to create a 32 bytes. Compiler actually will skip to
check the size the variable and fetch the whole 4 bytes in
data fetch operation. this will provide the aligned data to
MP in Single CPU cycle.
There is a Pragma directive, which override the compiler and
results the structure size with equal to size of variables.

Example:

Struct item {
int item;
char type;
};

Sizeof (struct item) = 8 bytes

Struct item {
int item;
char type[2];
short int value;
};
Sizeof (struct item) = 8 bytes

Struct item {
int item;
char type[3];
short int value;
};
Sizeof (struct item) = 12 bytes
one byte padded after "type" and 2 byes padded after value.



Bit-Wise: As far as I remember, it maintains a ARRAY of
int/char/bits equal to the number of elements defined inside
. The bit sets if some data is initialized with some value.
I am not sure on this.

Is This Answer Correct ?    4 Yes 1 No

Post New Answer

More C Interview Questions

What's wrong with "char *p; *p = malloc(10);"?

5 Answers  


What are types of structure?

0 Answers  


How do I send escape sequences to control a terminal or other device?

0 Answers  


WAP that prints the number from 1 to 100. but for multiplies of three print "XXX" instead of the number and for the multiplies of five print "YYY" . for number which are multiplies of both three and five print "ZZZ"

3 Answers  


How are pointers declared in c?

0 Answers  


There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?

0 Answers  


Do pointers store the address of value or the actual value of a variable?

0 Answers   Fidelity,


What is integer constants?

0 Answers  


A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor

0 Answers  


to find the program of matrix multiplication using arrays

6 Answers   Bhel,


Is there a way to switch on strings?

0 Answers  


What is non linear data structure in c?

0 Answers  


Categories