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.

Note: When COMPACT is specified, the compiler does not generate inline code for this function. In this case, you need to take either of the following actions:
  • Define the __METAL_SYSVEC feature test macro to use the system library.
  • Define the __METAL_STATIC feature test macro to use the static object library and bind in corresponding data set.

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