Given a data stream in C, I need to read the nth element which is x bits wide. x can vary from 1-64. How do I do this in C? I tried some bit fiddling but could not come up with a solution.
For example, for a data stream
01101010 11010101 11111111 00000010 00000000 10000000
==== ======
if the data is 10-bit wide and the element to parse is the third element. The expected data should be 1111 000000
.
The data stream is byte-addressable.