Bryan Adams
Bryan Adams

Reputation: 3

Bit operations on CHAR * in C

With reference to this thread: Decode FOUR_BITS of a byte in a byte array (in C)

The member idooo has given me a solution which can be seen there which involved a bit operation on a CHAR *. When I tried to compile, it gave me the error: '>>' : illegal, left operand has type 'unsigned char *'

I am looking for a solution for this. Thanks in advance.

PS: I can't change te data types. And the code snippet is given in that thread where I am doing the operations. Variables and their scopes are also explained there.

Upvotes: 0

Views: 216

Answers (1)

user4815162342
user4815162342

Reputation: 155186

The bit operations are on the dereferenced pointer, the type of which is char, not char *. So, if you have a char *ptr, your shift expression should be *prt >> 4, not ptr >> 4.

Upvotes: 2

Related Questions