C - String Manipulation Functions, memchr
Tutorials Point


  Learning C
  C Function References
  C Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     About TP     Advertising  

C - memchr function

previous

Synopsis:

#include <stdio.h>

void* memchr(const void* cs, int c, int n);

Description:

The memchr function scans cs for the character c in the first n bytes of the buffer.

Return Value

The memchr function returns a pointer to the character c in cs or a null pointer if the character was not found.

Example

#include <stdio.h>

int main() {
  char src [100] = "Search this string from the start";
  char *c;

  c = (char*)memchr (src, 'g', sizeof (src));

  if (c == NULL)
    printf ("'g' was not found in the src\n");
  else
    printf ("found 'g' in the src\n");

  return 0;
}

It will proiduce following result:

found 'g' in the src


previous Printer Friendly

Advertisements


  

Advertisements



Advertisements