fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <errno.h>
  5. int main() {
  6. char s[100+1],*e,*b = s;
  7. int d,i = 0;
  8. int num[20];
  9. fgets(s, 101, stdin);
  10.  
  11. for(d = strtol(b,&e,10); e != b && errno == 0;d = strtol(b = e,&e,10))
  12. {
  13. num[i++]= d;
  14. }
  15. puts(s);
  16. for(int j = 0; j < i; ++j)
  17. printf("%d ",num[j]);
  18. }
  19.  
Success #stdin #stdout 0s 4424KB
stdin
1 2 3 4 5 55 54 53 52 51
stdout
1 2 3 4 5 55 54 53 52 51

1  2  3  4  5  55  54  53  52  51