Copyright © tutorialspoint.com

C - strchr function

previous

Synopsis:

#include <stdio.h>

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

Description:

The strchr function searches string for the first occurrence of c. The null character terminating string is included in the search.

Return Value

The strchr function returns a pointer to the first occurrence of character c in string or a null pointer if no matching character is found.

Example

#include <stdio.h>

int main() {
  char *s;
  char buf [] = "This is a test";

  s = strchr (buf, 't');

  if (s != NULL)
    printf ("found a 't' at %s\n", s);

  return 0;
}

It will proiduce following result:

found a 't' at test

previous

Copyright © tutorialspoint.com