strchr strrchr functions
- strchr will find the first matching character in a string.
- strrchr will find the last matching character in a string.
The functions will return a pointer to the character or
NULL if
the character is not found.
Library: string.h
Prototype: char * strchr(const char *string, int character);
Syntax: int character='w';
char *string="red dwarf";
if(strchr(string, character)) puts("Character found");
See Also:
strstr which looks for a sub-string in a string.
strpbrk
index and rindex do the same as strchr
and strrchr but are non standard.
Example program (from Dave Doolin).
Martin Leslie