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's the right way to use errno?
What are external variables in c?
What is keyword in c?
Write a program in c to replace any vowel in a string with z?
What is chain pointer in c?
What does the error 'Null Pointer Assignment' mean and what causes this error?
Why do we use static in c?
Explain modulus operator. What are the restrictions of a modulus operator?
What are the complete rules for header file searching?
In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between 1 and N.Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the C*2 prime numbers from the center of the list if there are an even number of prime numbers or (C*2)-1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.
Disadvantages of C language.
Explain the difference between #include "..." And #include <...> In c?
Why is python slower than c?
a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list
What is the difference between a function and a method in c?