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
How do you list files in a directory?
With the help of using classes, write a program to add two numbers.
Why pointers are used in c?
what are the facialities provided by you after the selection of the student.
Explain what are preprocessor directives?
What’s a signal? Explain what do I use signals for?
What is a pointer on a pointer in c programming language?
Write a C program on Centralized OLTP, Decentralized OLTP using locking mechanism, Semaphore using locking mechanism, Shared memory, message queues, channel of communication, sockets and a simple program on Saving bank application program using OLTP in IPC?
Differentiate between the = symbol and == symbol?
Can you return null in c?
Explain what is the benefit of using an enum rather than a #define constant?
What extern c means?
What is the advantage of using #define to declare a constant?
will u please send me the placement papers to my mail???????????????????
Is javascript based on c?