fork download
  1. #include <stdio.h>
  2.  
  3. int calculator(void *yourVal){
  4. char *byte1;
  5. int byte3, byte5, byte7;
  6. int value;
  7.  
  8. byte1 = yourVal;
  9. byte3 = (byte1[2] - '0') * 10 + (byte1[3] - '0');
  10. byte5 = (byte1[4] - '0') * 10 + (byte1[5] - '0');
  11. byte7 = (byte1[6] - '0') * 10 + (byte1[7] - '0');
  12.  
  13. if(*byte1 == '*') {
  14. value = byte3 * byte5 * byte7;
  15. printf("You multiplied\n");
  16. return value;
  17. }
  18. else if(*byte1 == '/') {
  19. //omitted
  20. }
  21. else {
  22. printf("Your input is invalid\n");
  23. }
  24. return 0xBAD;
  25. }
  26.  
  27.  
  28. int main (void){
  29. printf("%d\n", calculator("*1234567"));
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 10320KB
stdin
Standard input is empty
stdout
You multiplied
69345