How to avoid structure padding in C?
Answer Posted / lakshman naganoor
By #pragma
Example:
#pragma pack(push,1)
struct mystruct_A {
int b;
short d;
double c;
char m;
};
#pragma pack(pop)
main()
{
printf("size of structure mystruct_Ad is %d\n",sizeof
(struct mystruct_A));
}
size of structure mystruct_Ad is 15
Note:size of structure mystruct_Ad without using #pragma
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is calloc in c?
What is malloc and calloc?
What are enums in c?
What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.
Should I learn data structures in c or python?
What is advantage of pointer in c?
Why we use break in c?
What are the application of c?
What is the difference between call by value and call by reference in c?
How reliable are floating-point comparisons?
What is the usage of the pointer in c?
What do you mean by dynamic memory allocation in c? What functions are used?
How would you rename a function in C?
What is the difference between single charater constant and string constant?
Differentiate between static and dynamic modeling.