3.2.22. memchr

Searches for a character in memory.

Syntax

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

where:

str1

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

byte_value

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

count

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

Description

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.

Rules

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

Example

This example shows how to use memchr:

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

See Also

Copyright © 2002-2009 ARM Limited. All rights reserved.ARM DUI 0175K
Non-Confidential