【疑惑记录】关于strtok函数计算单词数目的题目

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 101
int main(){
	char string[MAX];
	printf("plz enter a string:\n");
	gets(string);
	size_t counter=0;
	char *tokenPtr;
	tokenPtr=strtok(string," ");//use "" instead of ''
	while(tokenPtr!=NULL){
		tokenPtr=strtok(NULL," ");//i dont understand here
		counter++;
	}
	printf("total words is %d",counter);
}//strtok will change our original string

这里第二次初始化strtok的时候为什么要用strtok(NULL," ")呢

上一篇:字符串分割


下一篇:我怎样才能在Python中进行strtok() – 类型解析?