3.2.33. strchr

Locates the first occurrence of a character in a string.


char *strchr (str1, byte_value)
char *str1;
char byte_value;



This is a character pointer to the memory location of the first character byte in a string of characters.


This is a variable of character type, used to specify the character that the strchr macro must search for. The terminating NUL character '\0' is part of the string, so it can be searched for.


This macro locates the first occurrence of a character in a string.

Return value

char *

Points to the first memory location of the first occurrence of the character byte_value byte. 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 string searched on by strchr.


This example shows how to use strchr in a macro:

define /R void substr(character)
  char character;
  char *pos;
  pos = strchr("This is a string",character);
  $printf "position: %s\n",pos$;

See Also

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