fork download
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. using namespace std;
  5.  
  6. int extract_break_rewrites(int *m, int *n, const char *arg)
  7. {
  8. char m_str[10];
  9. char n_str[10];
  10. int count;
  11. const char * slash;
  12.  
  13. slash = strchr(arg, '/');
  14. if (slash != arg) {
  15. count = sscanf(arg, "%d", n);
  16. if (count != 1 || count == EOF)
  17. return -1;
  18. } else {
  19. *n = 0;
  20. }
  21. if (slash != NULL) {
  22. count = sscanf(slash + 1, "%d", m);
  23. if (count != 1 || count == EOF)
  24. return -1;
  25. } else {
  26. *m = 0;
  27. }
  28. return 1;
  29. }
  30.  
  31. int main() {
  32. int n,m;
  33. const char * command = "10%/60%";
  34. if (extract_break_rewrites(&m,&n,command)!=-1)
  35. cout<<"Successful. The values of m and n are "<<m<<" and "<<n<<", respectively.\n";
  36. else
  37. cout<<"There was error in processing, may be input was not in the correct format.\n";
  38. return 0;
  39. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
Successful. The values of m and n are 60 and 10, respectively.