fork(2) download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. //shift the array with length *len* *shift* bits to the left
  5. int len = 4, shift = 3;
  6. unsigned char a[] = "kxmo";
  7. unsigned char b[] = " "; //X@hx
  8.  
  9. int carry = 0, nextCarry;
  10. for(int i = len-1 ; i >= 0 ; i--) {
  11. nextCarry = (a[i] >> (8-shift)) & ((1<<(shift+1))-1);
  12. b[i] = (a[i] << shift) | carry;
  13. carry = nextCarry;
  14. printf("%x %x\n", a[i], b[i]);
  15. }
  16.  
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0s 2160KB
stdin
Standard input is empty
stdout
6f 78
6d 6b
78 c3
6b 5b