C strchr function example
Prototype: char * strchr (const char * s, char c );
# Include <string. h>
Searches for the position where character c appears for the first time in string s, and returns the pointer to the position where character c appears for the first time. If character c does not exist in string s, return NULL.
The strchr function finds the first occurrence of c instr, or it returns NULL ifc is not found. The null terminating character is supported in the search.
Example:
[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