C string strpbrk() 函数
定义和用法
strpbrk() 函数在字符串中搜索指定字符集的第一次出现,并返回指向字符串中该位置的指针。
如果未找到任何指定字符,则返回 NULL。
strpbrk() 函数定义在 <string.h> 头文件中。
实例
打印从第一个数字开始的字符串部分:
char myStr[] = "I think 4096 bytes should be enough";
char *pos = strpbrk(myStr, "0123456789");
if (pos != NULL) {
printf("%s", pos);
}
语法
strpbrk(void * str, void * search);
参数
| 参数 | 描述 |
|---|---|
| str | 必需。要搜索的字符串。 |
| search | 必需。包含要搜索的字符集的字符串。 |
技术细节
| 返回: |
返回指向搜索字符集中任何字符第一次出现位置的 如果未找到任何字符,则返回 |
|---|
相关页面
教程:C 字符串
教程:C 字符串函数