fork download
  1. #include <stdio.h>
  2. #include <errno.h>
  3. #include <stdlib.h>
  4.  
  5. int main(void) {
  6. const char *p = "10 200000000000000000000000000000 30 -40";
  7. printf("Parsing '%s':\n", p);
  8. char *end;
  9. for (unsigned long i = strtoul(p, &end, 10); p != end; i = strtoul(p, &end, 10)) {
  10. printf("'%.*s' -> ", (int)(end-p), p);
  11. p = end;
  12. if (errno == ERANGE) {
  13. printf("range error, got ");
  14. errno = 0;
  15. }
  16. printf("%lu\n", i);
  17. }
  18. }
  19.  
  20. //https://pt.stackoverflow.com/q/272801/101
Success #stdin #stdout 0s 5456KB
stdin
Standard input is empty
stdout
Parsing '10 200000000000000000000000000000 30 -40':
'10' -> 10
' 200000000000000000000000000000' -> range error, got 18446744073709551615
' 30' -> 30
' -40' -> 18446744073709551576