我必须在我的代码中实现位串(根据某些标准中给出的参数)。
一些标准参数是位串(具有不同的长度=3、7、24、1024 等)。
我将它们定义为:(示例:长度为 3 的位串)
#define SIZE 1
struct bt_string
{
/* Array will be min 1 Byte Long,
* this parameter stores the number of Bits
* actually being used */
unsigned short int bit_length;
char bit_string [SIZE];
} sample_bit_string;
我不允许使用位域。
有人可以建议(如果可能的话)任何更好的方法来实现这一点吗?