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 |
What are void pointers in c?
write a program to copy a string without using a string?
Without Computer networks, Computers will be half the use. Comment.
Explain why c is faster than c++?
Explain what are compound statements?
a simple c program using 'for' loop to display the output 5 4 3 2 1
What is the use of static variable in c?
What is a null pointer assignment error? What are bus errors, memory faults, and core dumps?
What are the types of i/o functions?
what will be the output off the following program? #include<stdio.h> int main() { int a; a=015+0*71+5; printf("%d,a"); return0; }
Is it valid to address one element beyond the end of an array?
What is the difference between call by value and call by reference in c?