c - C 中的位串

标签 c bitstring

我必须在我的代码中实现位串(根据某些标准中给出的参数)。

一些标准参数是位串(具有不同的长度=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;

我不允许使用位域。

有人可以建议(如果可能的话)任何更好的实现方法吗?

最佳答案

我想位图就是您要查找的内容。(wiki:http://en.wikipedia.org/wiki/Bitmap) 并且,从 Linux 内核移植的示例实现:http://code.google.com/p/ulib/source/browse/trunk/src/base/bitmap.c .

关于c - C 中的位串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15035754/

相关文章:

java - 数据加密标准

python - 使用 Python 位串测量霍夫曼编码的效率

algorithm - (n 选择 k) 和长度为 n 的位串之间的双射,其中设置了 k 位

c - 在 C 中修改链表项的正确方法

c - 在简单的 shell 中实现历史函数(C 语言)

c - 处理函数和指针

c - 生成的依赖项与生成的文件

c - 二维数组错误: Subscripted value is neither array nor pointer nor vector

matlab - 在matlab中有效计算汉明权重

c++ - 在指定的位偏移处读/写一个值