What are bit fields? What is their use?

Answers were Sorted based on User's Feedback



What are bit fields? What is their use?..

Answer / ravi joshi

Bit fields can only be declared inside a structure or a
union, and allow you to specify some very small objects of a
given number of bits in length. Their usefulness is limited
and they aren't seen in many programs, but we'll deal with
them anyway.

Is This Answer Correct ?    6 Yes 0 No

What are bit fields? What is their use?..

Answer / vadivel t

Bit fields main intention is to reduce the memory
consumption.

Syntax:
------

struct
{
int a:1;
/*whatever may be the size of the int(compiler dependent),
only one bit shall be allocated for variable 'a'*/
}BITFIELDS;

Restictions:
------------
1. Accessing or printing address of bitfield variable is
not possible.
2.Array of bit fields, not possible.
3.A function cannot return a bit field variable.

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More C Interview Questions

The program to allow the characters from the input received and send this function to a function check if the characters between letters a to z is a function of y joins as the characters main and output to otherwise return to the original function of the y characters

0 Answers  


the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset

0 Answers  


Is the C language is the portable language...If yes...Then Why...and if not then what is problem so it is not a Portable language..???

2 Answers   TCS,


Is there a way to switch on strings?

0 Answers  


What is the scope of local variable in c?

0 Answers  






How can I read a directory in a C program?

2 Answers   Bright Outdoor, Wipro,


12. Look at the Code: main() { int a[]={1,2,3},i; for(i=0;i<3;i++) { printf("%d",*a); a++; } } Which Statement is/are True w.r.t the above code? I.Executes Successfully & Prints the contents of the array II.Gives the Error:Lvalue Required III.The address of the array should not be changed IV.None of the Above. A)Only I B)Only II C)II & III D)IV

4 Answers   Accenture,


If the static variable is declared as global, will it be same as extern?

1 Answers   Samsung,


What is integer constants?

0 Answers  


Write a function to find the area of a triangle whose length of three sides is given

2 Answers  


Why is #define used?

0 Answers  


We can draw a box in cprogram by using only one printf();& without using graphic.h header file?

4 Answers   NIIT,


Categories