fork download
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5. char c;
  6. int x;
  7.  
  8. c = getchar();
  9. switch (c) {
  10. case '0' :
  11. x = 0; break;
  12. case '1' :
  13. x = 1; break;
  14. case '2' :
  15. x = 2; break;
  16. case '3' :
  17. x = 3; break;
  18. case '4' :
  19. x = 4; break;
  20. case '5' :
  21. x = 5; break;
  22. case '6' :
  23. x = 6; break;
  24. case '7' :
  25. x = 7; break;
  26. case '8' :
  27. x = 8; break;
  28. case '9' :
  29. x = 9; break;
  30. default :
  31. x = 0; break;
  32. }
  33.  
  34. printf("c: %c | x: %d\n", c, x);
  35.  
  36. return (0);
  37. }
  38.  
Success #stdin #stdout 0s 1836KB
stdin
5
x
stdout
c: 5 | x: 5