fork download
  1. #include <stdio.h>
  2. #include <errno.h>
  3. #include <stdlib.h>
  4.  
  5. int main()
  6. {
  7. char *s = "-1d+10h+5m-1s+1h-10m";
  8. long x;
  9. errno = 0;
  10. while ( x = strtol(s, &s, 10), x!=0 && errno == 0)
  11. printf("%ld%c", x,*s++);
  12. return 0;
  13. }
  14.  
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
-1d10h5m-1s1h-10m