strchr, strrchr
strchr, strrchr — search a string for an individual character.
strchr (string, char_as_string)
strrchr (string, char_as_string)
stringAny character string.
char_as_stringA string containing the one character to be found.
The position of the char_as_string within the
string, where the first character is in position
zero. If the char_as_string is not found in the
string, returns -1. strchr
returns the first occurrence of the character in the string.
strrchr returns the last occurrence of the
character in the string.
These functions search a string for an individual character and return the first or last occurrence of that character within the string. The characters within a string are numbered starting at zero.
Gamma>strchr("apple","a");0Gamma>strchr("apple","r");-1Gamma>strchr("apple","p");1Gamma>strrchr("apple pie","p");6Gamma>