code:
#include<stdio.h> #include<stdlib.h> int main(){ char line[]="1 -2 10000 -50 20 7 445 -4"; char *p,*e; long input; int counts =0; p=line; for(p=line; ;p=e) { input = strtol(p,&e,10); if(p==e) { break; } counts++; } printf("%d\n",counts); return 0; }