Guardian C Library Calls Reference Manual

Reference to Library Calls
Guardian TNS C Library Calls Reference Manual128833 3-193
strchr
strchr
The strchr function scans a string for the first occurrence of a given character.
str_ptr
points to the string to scan.
chr
is the character to scan for.
Return Value
points to the first occurrence in *str_ptr of chr. If *str_ptr does not contain chr, then
strchr returns the pointer value NULL.
Example
This example searches string s for the character “a” and prints the character:
#include <stringh>
#include <stdioh>
int main(void)
{
char *p;
char *s;
int c;
c = 'a';
s = "This is an example";
p = strchr(s, c);
printf("%c", *p);
}
#include <stringh>
char *strchr(const char *str_ptr, int chr);