what is the use of #pragma pack, wer it is used?

Answer Posted / ram

actually pragma pack is used for structure padding
we are having #pragma pack 0,#pragma pack 1,#pragma pack
2,#pragma pack 3,#pragma pack 4
in this first one will allocate memory 4 bytes for every
data type
in second one i.e in pack 1 it allocates 1 byte for every
data type
in third one i.e in pack 2 it allocates 2 bytes for every
data type
in fourth one i.e pack 3 it allocates 3 bytes for every data
type
in fifth one i.e pack 4 it allocates 4 bytes for every data type

Actually pragma will be used in powers of 2 only

Is This Answer Correct ?    3 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what will be maximum number of comparisons when number of elements are given?

1406


What is structure padding in c?

618


What is structure and union in c?

594


Explain what are multidimensional arrays?

596


how to count no of words,characters,lines in a paragraph.

3897






What are different storage class specifiers in c?

611


When is a “switch” statement preferable over an “if” statement?

639


What is the difference between new and malloc functions?

572


Write a program to print factorial of given number without using recursion?

564


What is the use of ?: Operator?

660


Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)

805


Explain about the constants which help in debugging?

843


What is a program?

655


What is c++ used for today?

657


What is the difference between #include

and #include “header file”?

544