C Programming - Structures, Unions, Enums - Discussion

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

int main()
{
    struct a
    {
        float category:5;
        char scheme:4;
    };
    printf("size=%d", sizeof(struct a));
    return 0;
}
Error: invalid structure member in printf
Error in this float category:5; statement
No error
None of above
Answer: Option
Explanation:

Bit field type must be signed int or unsigned int.

The char type: char scheme:4; is also a valid statement.

Discussion:
25 comments Page 3 of 3.

Rahul said:   1 decade ago
What is signed int or unsigned int?

Sudha said:   1 decade ago
Nice explanation friends. Thanks.

Ashwani said:   1 decade ago
Can anyone explain this please ?

K.maheswari said:   1 decade ago
Any one explain this concept ?

Santosh said:   1 decade ago
Please someone explain this.


Post your comments here:

Your comments will be displayed after verification.