int countSegments(char * s){ int count=0; char* tok; tok = strtok(s," "); while (tok) { count++; tok = strtok(NULL, " "); } return count; }