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
FILE PROGRAMMING
Explain output of printf("Hello World"-'A'+'B'); ?
What is void pointers in c?
What are derived data types in c?
What is the difference between typedef struct and struct?
Not all reserved words are written in lowercase. TRUE or FALSE?
Why pointers are used?
What are file streams?
Explain the difference between structs and unions in c?
Can a pointer point to null?
How can I call fortran?
What is the purpose of main() function?
What are variables c?
Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?
Why do we use static in c?