English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C Standard Library - <string.h>
C 库函数 char *strchr(const char *str, int c) 在参数 str 所指向的字符串中搜索第一次出现字符 c(一个无符号字符)的位置。
下面是 strchr() 函数的声明。
char *strchr(const char *str, int c)
该函数返回在字符串 str 中第一次出现字符 c 的位置,如果未找到该字符则返回 NULL。
下面的示例演示了 strchr() 函数的用法。
#include <stdio.h> #include <string.h> int main () { const char str[] = "http:";//fr.oldtoolbag.com"; const char ch = '.'; char *ret; ret = strchr(str, ch); printf("|%c| The following string is" - "%|s|\n", ch, ret); return(0); }
Let's compile and run the above program, which will produce the following result:
|.| The following string is - |.oldtoolbag.com|