C Programming - Structures, Unions, Enums - Discussion
Discussion Forum : Structures, Unions, Enums - Yes / No Questions (Q.No. 9)
9.
Can we have an array of bit fields?
Discussion:
10 comments Page 1 of 1.
Shubh said:
5 years ago
@Arun Prasad nice explanation.
Aash said:
6 years ago
Bit fields are usually in contagious locations which are represent variables in bits format so to create an array it should be taken by a pointer but they are of bytes type so cannot form an array of bits. (i just assumption only).
Gomathi said:
8 years ago
It's not clear. Please explain me.
Jig's Patel said:
9 years ago
Whenever we dealing with a bit field must and should be mention unsigned otherwise its takes the first bit as a signed bit(+ or -).
In this, it is not possible to declare a float, scan f [bcz scan f need &(address) and in this, we can't print address also] and also not use the size of operator.
In this, it is not possible to declare a float, scan f [bcz scan f need &(address) and in this, we can't print address also] and also not use the size of operator.
Rithi said:
9 years ago
Didn't understand. Please explain me.
Saikiran said:
9 years ago
Why bit field must be integral type?
Patel said:
1 decade ago
What is bit field?
Arun Prasad said:
1 decade ago
Bit Fields must have integral type. We cannot define an array of bit fields. Because arrays are working like pointers. For ex. *(a+i). Pointers can access memory in Bytes. It requires min. memeory 1 byte like char variable. But it can't access bit memory. That's why we never use pointers in bit fields. we can declare a bit field as
struct a
{
int a:3;
int b:5;
};
but we can't declare it as
struct a
{
int a[2]:5; // bit field must be integral type.
};
struct a
{
int a:3;
int b:5;
};
but we can't declare it as
struct a
{
int a[2]:5; // bit field must be integral type.
};
(1)
Javed said:
1 decade ago
struct taxonomy {
int kingdom : 12;
int phylum : 6;
int genus : 2;
};
The following structures has three bit-field members kingdom,phylum,genus occupying 12,6 and 2 bits fields.
The above example will provide you a brief explanation of array of bit-fields.
int kingdom : 12;
int phylum : 6;
int genus : 2;
};
The following structures has three bit-field members kingdom,phylum,genus occupying 12,6 and 2 bits fields.
The above example will provide you a brief explanation of array of bit-fields.
Nitin said:
1 decade ago
What do this question means?
Array of bitfields?
Array of bitfields?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers