Question about bit arrays and bit interpolation in C

P

Pratap Das

Hi all,
Is there any concept of bit arrays and routines to manipulate them in
C?
Basically I need to form bit arrays of different sizes eg: 5 bits , 6
bits etc and then interpolate the bits of these arrays together to
form a big array...ie some kind of bit interleaving.
What is the most efficient way to do that in C? If I use uint8 etc
then eventually I am wasting some bits.
Thanks for all the help in advance.
--Das
 
R

Richard Heathfield

Pratap said:
Hi all,
Is there any concept of bit arrays and routines to manipulate them in
C?

No, but it's trivial to invent and implement such a concept.

See http://www.snippets.org for some handy bit-hacking macros that work on
arrays of unsigned char. You should be able to fit CHAR_BIT bits into each
element of the array, thus wasting no space whatsoever.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top