What is structure padding & expalain wid example
what is bit wise structure?
Answer Posted / 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 View All Answers
What are the standard predefined macros?
hi send me sample aptitude papers of cts?
How does selection sort work in c?
What is the difference between #include and #include 'file' ?
Can a variable be both static and volatile in c?
What are multidimensional arrays?
What is bash c?
Write a C program on Centralized OLTP, Decentralized OLTP using locking mechanism, Semaphore using locking mechanism, Shared memory, message queues, channel of communication, sockets and a simple program on Saving bank application program using OLTP in IPC?
What are loops in c?
how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software
Differentiate between Macro and ordinary definition.
How many levels deep can include files be nested?
What is static and volatile in c?
Explain setjmp()?
What is call by reference in functions?