Re[3]: [Dev-C++] using char* as bitfield
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <ca...@kr...> - 2003-09-29 15:13:27
|
hi Per,
Monday, September 29, 2003, 5:04:14 PM, you wrote:
> Yes, it is possible to do with char*
> char* alloc_bits(unsigned bits) {
> char *bits;
> unsigned size;
> size = (bits+7)/8;
> bits = malloc(size);
> if (bits) memset(bits,0,size);
> return bits;
> }
> void set_bit(char* bits,unsigned bit) {
> array[bit/8] |= 1 << (bit&3);
> }
> char *mybits;
> mybits = alloc_bits(1000);
> if (mybits) set_bit(mybits,117);
> /Per W
wow, thanks!
gruss
/Christian mailto:ca...@kr...
---
I propose that the following character sequence for joke markers:
:-)
19-Sep-82 11:44 Scott E Fahlman
|