原型: char *strchr(const char *s,char c);
#include<string.h>
查找字符串s中首次出现字符c的位置,返回首次出现c的位置的指针,如果s中不存在c则返回NULL。
The strchr function finds the first occurrence of c instr, or it returns NULL ifc is not found. The null terminating character is included in the search.
实例讲解:
[root@bdkyr xuekun]# vim strchr_test.c
/*
* create by xuekun
* date 2015-7-31
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
main()
{
char *s="Golden Global View";
char *p;
p=strchr(s,'V');
if(p)
printf("%s\n",p);
else
printf("Not Found!\n");
return 0;
}
[root@bdkyr xuekun]# gcc strchr_test.c -o strchr_test
[root@gateway xuekun]# ./strchr_test
View