In C I saw this code:
struct stud{
int b:3;
};
This was compiling in gcc.
What do variables b and 3 represent? Also, please explain the use of :.
Are there anymore signs like this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It means that
buses 3 bits of the int. The term is “bit field”.Usually this is combined with other variables using other bits of the same or other ints.
The idea is to either pack values harder to save space, or more common to match the data from some hardware device.