输入一个包含逗号的字符串
输出以逗号作为分隔的两个字符串的长度
#include <stdio.h>
#include <string.h>
int main()
{
char buf[100];
scanf("%s",&buf);
const char s[2] = ",";//分隔英文逗号
char *token;
/* 获取第一个子字符串 */
token = strtok(buf, s);
/* 继续获取其他的子字符串 */
while( token != NULL ) {
printf( "%d\n", strlen(token));
token = strtok(NULL, s);
}
return 0;
}