Pointer to the null-terminated string to be searched.
2nd Parameter Type : int
Integer type (typically 4 bytes, -2,147,483,648 to 2,147,483,647)
2nd Parameter
The character to locate in the string, passed as an `int` but internally converted to `char`.
Read more about parameters of strchr in parameters section
The strchrfunction in C language Searches for the first occurrence of the character in the string.
The strchr function locates the first occurrence of c (converted to a char) in the string pointed to by s. The terminating null character is considered to be part of the string. If c is '\0', strchr locates the terminating '\0'.
The strchrfunction takes 2
parameters:
•
const char * `str`: Pointer to the null-terminated string to be searched.
•
int `c`: The character to locate in the string, passed as an `int` but internally converted to `char`.
Searches the string `str` for the first occurrence of the character `c`. Returns a pointer to the first occurrence of the character in the string, or `NULL` if the character is not found.
The strchr function return value :
Returns a pointer to the located character, or NULL if the character does not appear in the string
Output
This example demonstrates basic usage of strchr to find the first occurrence of 'o' in a string.