C Programming - Structures, Unions, Enums - Discussion

Discussion Forum : Structures, Unions, Enums - Point Out Errors (Q.No. 7)
7.
Point out the error in the program in 16-bit platform?
#include<stdio.h>

int main()
{
    struct bits
    {
        int i:40;
    }bit;

    printf("%d\n", sizeof(bit));
    return 0;
}
4
2
Error: Bit field too large
Error: Invalid member access in structure
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
19 comments Page 2 of 2.

Sugandh said:   1 decade ago
I reduced is size to "2".
int i:2, still I am getting the same error.

Varsha Shinde said:   1 decade ago
What is the difference between i = 40 and i:40? Can you just explain it?

Santosh said:   1 decade ago
I:30 is right and it will give output 4 in 32-bit OS.

Deepak said:   1 decade ago
If we assign like int i:30;

Is it right or wrong ?

Ram said:   1 decade ago
int i:40;

What does it mean the above statement?

Kamal said:   1 decade ago
'i:40' it means allocating the bit size for i.

Deepak said:   1 decade ago
What is its mean? please explain it clearly.

Vimal said:   1 decade ago
What is meant by "i:40"?

Chanders said:   1 decade ago
Yes, you are apsolutely correct.


Post your comments here:

Your comments will be displayed after verification.