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

Answers were Sorted based on User's Feedback



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

Answer / sarabjit kaur

#pragma is a miscelleneous directive which is used to turn
on or off certain features.
It varies frm compiler to compiler
a. #pragma startup and #pragma exit
used to specify which function should b called upon startup
(before main()) or program exit(just before program
terminates)
such funtions should nt receive or return any valur

b. #pragma -warn used to surpress specific warning
#pragma warn -rvl return value warnings surpressed
#pragma warn -par parameter not used warnings surpressed
#pragma warn -rch unreachable code warnings surpressed

Is This Answer Correct ?    2 Yes 3 No

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

Answer / 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

More C Interview Questions

How can I implement a delay, or time a users response, with sub-second resolution?

0 Answers  


write a program to search for an element in a given array. If the array was found then display its position otherwise display appropriate message in c language

18 Answers   IT Park, TCS,


Why can't we initialise member variable of a strucutre

1 Answers  


Which header file is essential for using strcmp function?

0 Answers  


What is pointers in c?

0 Answers  






Difference between malloc() and calloc() function?

0 Answers  


What is the output for the following program #include<stdio.h> main() { char a[5][5],flag; a[0][0]='A'; flag=((a==*a)&&(*a==a[0])); printf("%d\n",flag); }

5 Answers   ADITI, Wipro,


provide an example of the Group by clause, when would you use this clause

0 Answers  


Why is c called c?

0 Answers  


who did come first hen or agg

15 Answers   Infosys,


What is structure data type in c?

0 Answers  


A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers

0 Answers  


Categories