C memchr function searches memory for character

Syntax

C memchr function has the following syntax.

void *memchr(const void *buffer, int ch, size_t count);

C memchr function is from header file string.h.

Description

C memchr function searches *buffer for 'ch' in the first count characters and returns a pointer to the first occurrence of ch or a null pointer if not found.

Example

Use C memchr function to search a string.


#include <stdio.h>
#include <string.h>
//w  ww  . java 2 s .  c  om
int main(void)
{
  char *p;

  p = memchr("this is a test", ' ', 14);
  printf(p);

  return 0;
}




















Home »
  C Language »
    Function Reference »




assert.h
ctype.h
math.h
setjmp.h
signal.h
stdio.h
stdlib.h
string.h
time.h
wctype.h