3.2.22. memchr

Searches for a character in memory.


char *memchr (str1, byte_value, count)
char *str1;
char byte_value;
int count;



A character pointer to the memory location of the first character byte in a string of characters contained in a file.


A character variable used to copy the memory contents of the character occupying a specific position in a character string.


An integer variable that specifies the number of characters in str that are to be searched for the character specified by byte_value.


This macro searches for a character in memory. The memchr macro locates the first occurrence of the character byte_value, that is contained in the first count bytes of memory area that begins with the memory location pointed to by the start variable, str1.

Return value

char *

A pointer to the instance of the character being searched for, called byte_value, if one is found. If no instance of the character being searched for is found, then a NULL pointer is returned.


For debugger variables only, a -1 value (0xFFFFFFFF) is returned when byte_value does not occur in the memory searched on by memchr.


This example shows how to use memchr:

define /R void memoryChr()
  char buff[37];
  char *posn;
  posn = memchr(buff,'d',20);
  $printf "%s\n",posn$;

See Also

Copyright © 2002-2011 ARM. All rights reserved.ARM DUI 0175N