how to declare an unsigned int in a C program

房东的猫 提交于 2019-12-05 07:44:04

I think you have come across a bit-field :)

It's part of a struct, which means that it indicates that the field should only use a certain number of bits instead of an entire byte or more.

This is bit field declaration in an array. The number post ":" denotes number of bits to allocate to this particular field of the structure.

Although you need to be careful with bit-fields as their binary representation is not portable. That is you are passing binary blobs between interfaces compiled with different compilers it may not work.

This indicates that only one bit of this will be used.

In structs, one can have integer variables that occupy any number of bits between 1 and 31. is_added is such a one-bit variable. One-bit variables are also known as flags.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!