C memchr function

« Previous

Synopsis:

Example

#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

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 source\n");
  else
    printf ("found 'g' in The source\n");
  return 0;
}

Output Will Be :

Output

found 'g' in The source


« Previous
Have Any Suggestion? We Are Waiting To Hear from YOU!

Your Query was successfully sent!