原型: 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