strchr function(Search String for Character) in C Language – example and detail

In the C Programming Language, the strchr function searches within the string pointed to by s for the character c. It returns a pointer to it.


The syntax for the strchr function in the C Language is:

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

Parameters or Arguments

s A string (terminated by means of a null character). c The character to be found.


The strchr feature returns a pointer to the first occurrence of the character c inside the string pointed to by way of s. If c isn’t always found, it returns a null pointer.

Required Header

In the C Language, the required header for the strchr characteristic is:

#include <string.h>

Applies To

In the C Language, the strchr feature can be used in the following versions:

ANSI/ISO 9899-1990

Similar Functions

Other C functions that are comparable to the strchr function:

memchr function

See Also

Other C functions that are noteworthy when dealing with the strchr function:

strpbrk feature strrchr function strstr function