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
Explain the use of function toupper() with and example code?
What functions are used for dynamic memory allocation in c language?
swap 2 numbers without using third variable?
write a program fibonacci series and palindrome program in c
Write a program to reverse a given number in c?
Explain enumerated types in c language?
What does #pragma once mean?
Define C in your own Language.
How to explain the final year project as a fresher please answer with sample project
Write a program to reverse a given number in c language?
What is #define size in c?
what is the structure pointer?
What is use of null pointer in c?
Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?
What is the size of structure pointer in c?