Loading... <div class="tip inlineBlock success"> strchr的作用:在字符串中查找,字符串中出现的第一个字符 </div> ### 须包含头文件: #include<stdio.h> #include <stdlib.h> #include<string.h> ### 用法: strchr(字符串,查找的字符); ### 代码实例: ```cpp #include<stdio.h> #include <stdlib.h> #include<string.h> int main(void) { char s[]={"AAPATAA"}; char *p1; p1=strchr(s,'P'); //strchr() 用来查找某字符在字符串中首次出现的位置,其原型为: printf("%d\n",p1 - s); // 'p'首次出现的位置 system("pause"); return 0; } ``` 最后修改:2021 年 08 月 28 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果文章有用,请随意打赏。