Keil Logo

memchr

Summary
#include <string.h>

void *memchr (
  void *buf,         /* buffer to search */
  unsigned char c,   /* byte to find */
  unsigned int len); /* maximum buffer length */
Description

The memchr function scans buf for the character c in the first len bytes of the buffer.

Return Value

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

See Also

memccpy, memcmp, memcpy, memmove, memset

Example
#include <string.h>
#include <stdio.h> /* for printf */

void tst_memchr (void) {
  static char src1 [100] = "Search this string";
  void *c;

  c = memchr (src1, 'g', sizeof (src1));

  if (c == NULL)
    printf ("'g' was not found in the buffer\n");
  else
    printf ("found 'g' in the buffer\n");
}
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.