I'll take you at your word about trying for some time, but it is generally advisable to post more of the code that show it. That said, I like messing with bits, so this is what I was playing with:
Code:
#include <stdio.h>
#include <limits.h>
void show(const void *object, size_t size)
{
const unsigned char *byte;
for ( byte = object; size--; ++byte )
{
unsigned char mask;
for ( mask = 1 << (CHAR_BIT - 1); mask; mask >>= 1 )
{
putchar(mask & *byte ? '1' : '0');
}
putchar(' ');
}
putchar('\n');
}
void shiftl(void *object, size_t size)
{
unsigned char *byte;
for ( byte = object; size--; ++byte )
{
unsigned char bit = 0;
if ( size )
{
bit = byte[1] & (1 << (CHAR_BIT - 1)) ? 1 : 0;
}
*byte <<= 1;
*byte |= bit;
}
}
int main()
{
/* 11110000 11001100 10101010 11110000 */
unsigned char array[] = { 0xF0, 0xCC, 0xAA, 0xF0};
show(array, sizeof array);
shiftl(array, sizeof array);
show(array, sizeof array);
return 0;
}
/* my output
11110000 11001100 10101010 11110000
11100001 10011001 01010101 11100000
*/