Reputation:
can i use bitwise on the entire char array?
working example:
unsigned int aNumInt= 0xFFFF; //1111111111111111
aNumInt = aNumInt << 8; // 1111111100000000
is it possible to do the same with an entire array of char?
NOT working example:
unsigned char aCharInt[2]={0xFF,0xFF}; //1111111111111111
aCharInt = aCharInt << 8; //<-- this does not work.. using it as an example
// 1111111100000000
or do is the only way to go is by going with byte per byte
aCharInt[1] = aCharInt[1] << 8;
or memcpy
Upvotes: 0
Views: 208
Reputation: 754570
You can seldom operate on all the elements of an array at once in C. One of the few exceptions is if you have an array that is part of a structure; then you can copy the elements of the array as part of a structure assignment. But that doesn't apply here.
Shift operations or other bitwise operators would have to be applied to each element in turn.
Upvotes: 1