int countSegments(char * s){ int count=0; char* tok; tok = strtok(s," "); while (tok) { count++; tok = strtok(NULL, " "); } return count; }
【leetcode】字符串中的单词数
原文:https://www.cnblogs.com/ganxiang/p/13665156.html