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 what is the most efficient way to store flag values?
What is the difference between #include
What is meant by 'bit masking'?
Explain how can I avoid the abort, retry, fail messages?
which of the following shows the correct hierarchy of arithmetic operations in C a) (), **, * or/,+ or - b) (),**,*,/,+,- c) (),**,/,*,+,- d) (),/ or *,- or +
how do you execute a c program in unix.
typedef enum { html, java, javascript, perl, cgi } lang;The above statement defines a : a) Union b) User defined type c) Enumerated variable d) none
explain what are pointers?
Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
What is far pointer in c?
Describe the steps to insert data into a singly linked list.
How can I ensure that integer arithmetic doesnt overflow?
What do mean by network ?
What are the 4 types of functions?
What are different types of pointers?