fork(4) download
  1. #include <stdio.h>
  2. #include <stdint.h>
  3.  
  4. uint32_t reverse_bytes(uint32_t bytes)
  5. {
  6. uint32_t aux = 0;
  7. uint8_t byte;
  8. int i;
  9.  
  10. for(i = 0; i < 4; ++i)
  11. {
  12. byte = (bytes >> 8 * i) & 0xff;
  13. aux |= byte << (24 - 8 * i);
  14. }
  15. return aux;
  16. }
  17.  
  18. int main(void) {
  19. // your code goes here
  20. uint32_t input = 0x123456;
  21. printf("input: 0x%08x\n", input);
  22. input = reverse_bytes(input);
  23. printf("input: 0x%08x\n", input);
  24. return 0;
  25. }
Success #stdin #stdout 0s 2160KB
stdin
Standard input is empty
stdout
input: 0x00123456
input: 0x56341200