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 the purpose of 'register' keyword?
Why functions are used in c?
What does stand for?
what value is returned to operating system after program execution?
How can I change their mode to binary?
What is equivalent to ++i+++j?
What is a void pointer? When is a void pointer used?
What is structure pointer in c?
What is the value of c?
How can you find out how much memory is available?
Explain what header files do I need in order to define the standard library functions I use?
What is a far pointer in c?
Explain 'bit masking'?
Explain how do I determine whether a character is numeric, alphabetic, and so on?
Can you assign a different address to an array tag?