strchr() — Search for Character

Format

#include <string.h>

char *strchr(const char *string, int c);

General Description

The strchr() built-in function finds the first occurrence of c converted to char, in the string *string. The character c can be the NULL character (\0); the ending NULL character of string is included in the search.

The strchr() function operates on NULL-terminated strings. The string argument to the function must contain a NULL character (\0) marking the end of the string.

Returned Value

If successful, strchr() returns a pointer to the first occurrence of c (converted to a character) in string.

If the character is not found, strchr() returns a NULL pointer.

Related Information