fork download
  1. #include <stdio.h>
  2.  
  3. unsigned concatenate(unsigned x, unsigned y) {
  4. unsigned pow = 10;
  5. while (y >= pow) pow *= 10;
  6. return x * pow + y;
  7. }
  8.  
  9. void unconcatenate(unsigned *first, unsigned *second, unsigned concatenated, unsigned limit) {
  10. unsigned pow = 10;
  11. while (pow < limit) pow *= 10;
  12. *first = concatenated / pow;
  13. *second = concatenated % pow;
  14. }
  15.  
  16. int main(void) {
  17. unsigned x, y, foo = concatenate(1234, 56);
  18.  
  19. unconcatenate(&x, &y, foo, 100);
  20. printf("%u unconcatenaded to %u and %u.\n", foo, x, y);
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 5436KB
stdin
Standard input is empty
stdout
123456 unconcatenaded to 1234 and 56.