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
How to Throw some light on the splay trees?
Write a C program to help a HiFi’s Restaurant automate its breakfast billing system. Your assignment should implement the following items: a. Show the customer the different breakfast items offered by the HiFi’s Restaurant. b. Allow the customer to select more than one item from the menu. c. Calculate and print the bill to the customer. d. Produce a report to present your complete program and show more sample output. Assume that the HiFi’s Restaurant offers the following breakfast menu: Plain Egg $2.50 Bacon and Egg $3.45 Muffin $2.20 French Toast $2.95 Fruit Basket $3.45 Cereal $0.70 Coffee $1.50 Tea $1.80
The statement, int(*x[]) () what does in indicate?
What is the correct declaration of main?
What are the types of macro formats?
What is %s and %d in c?
What is the purpose of void pointer?
WRITE A CODE IN C TO SEARCH A FILE FROM NOTEPAD FILE.
What is register variable in c language?
What is the difference between #include and #include 'file' ?
Explain what happens if you free a pointer twice?
Explain the term printf() and scanf() used in c language?
What is d scanf?
How to implement a packet in C
What does. int *x[](); means ?