1 strstr:
The strstr() function finds the first occurrence of the substring needle in the string haystack. The terminating null bytes ('\0') are not compared.
The strcasestr() function is like strstr(), but ignores the case of both arguments.
在串中查找指定字符串的第一次出现
2 strtok:
The strtok() function breaks a string into a sequence of zero or more nonempty tokens. On the first call to strtok() the string to be parsed should be specified in
str. In each subsequent call that should parse the same string, str must be NULL.
用于在一个字符串中遍历查找子串
例子:
#include <string .h>
int main(int argc, char* argv[])
{
char *p=NULL;
char str[] ="123,4567,8,9,01,44";
const char * split = ",";
p = strtok (str,split);
while(p!=NULL) {
printf ("%s %d\n",p,strlen(p));
p = strtok(NULL,split);
}
return 0;
}
3 setlocale:
设置程序执行的编码环境,会影响字符串长度的计算(比如中文字符串的长度)