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

What is the concatenation operator?

0 Answers  


Tell me what is the purpose of 'register' keyword in c language?

0 Answers  


what is the code for getting the output as * ** ***

5 Answers   Caritor,


Find the largest number from the given 2 numbers without using any loops and the conditional operator.

2 Answers  


Find the highest of three numbers and print them using ascending orders?

1 Answers  






void swap(int a,int b) { a=a+b; b=a-b; a=a-b; } in this code always gives the same result for all case

9 Answers   Accenture, TCS,


how can we Declare a variable in c without defining it.

1 Answers   TCS,


what is the use of c program?

4 Answers   Synergy, Web Synergies,


What is meant by inheritance?

0 Answers  


What does do in c?

0 Answers  


How variables are declared in c?

0 Answers  


What is a header file?

0 Answers  


Categories