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 a pragma?
given post order,in order construct the corresponding binary tree
Explain Basic concepts of C language?
What is 'bus error'?
how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software
What do you understand by normalization of pointers?
What is a lookup table in c?
What is the advantage of an array over individual variables?
Explain the concept and use of type void.
What is the auto keyword good for?
What is local and global variable in c?
Write a program to know whether the input number is an armstrong number.
What is a loop?
What are qualifiers?
What do mean by network ?