Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 256 位的 C 数组,声明如下:
unsigned bitmap[8]
我想将具体位设置为 1,所以通常我会这样做bitmap[0] = 1<<2,例如,这会给我000 0100,但是如果我想在我的位图中将 34 位设置为 1,那么有什么好方法呢?
bitmap[0] = 1<<2
000 0100
那么这个问题的答案是
bitmap[34/32] |= 1 << (34%32);
并来自这里 ->位数组