How to avoid structure padding in C?
Answer Posted / santosh
Packing, on the other hand prevents compiler from doing padding - this has to be explicitly requested - under GCC it's __attribute__((__packed__)), so the following:
struct __attribute__((__packed__)) mystruct_A {
char a;
int b;
char c;
};
Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
What are the 5 types of organizational structures?
How can I automatically locate a programs configuration files in the same directory as the executable?
simple program of graphics and their output display
write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.
One of the Institutes contains 5 student groups. Every group contains 4 students. Institute wants to store student group’s details in array. Group should contain group member’s details (name and registration number and age), project name, and mark of the group.
What is the benefit of using #define to declare a constant?
What are static variables in c?
What are the advantages of using Unions?
What is nested structure in c?
How do we print only part of a string in c?
Where local variables are stored in c?
Write a program that takes a 5 digit number and calculates 2 power that number and prints it(should not use big integers and exponential functions)
Difference between macros and inline functions? Can a function be forced as inline?
Why is it that not all header files are declared in every C program?
Can we compile a program without main() function?