3.2.37. strlen

Returns the length or the specified string.


unsigned long strlen (str1)
char *str1;



Variable of type pointer to char. Specifies the location in memory of the first byte of a character string.


This macro returns the string length. The strlen macro counts the number of characters in a string up to but not including the NUL terminating character.

This macro behaves like the strlen function in the ANSI C string library.

Return value

unsigned long

Return value is equal to the number of characters in the string pointed to by str1, not including the terminating NUL character.


  • Strings are assumed to be NUL terminated.

  • If str1 is not properly terminated by a NUL character, the length returned is invalid.


This example shows how to use strlen on the command line:

> ce strlen("1234567890")
  Result is: 10  0x0000000A

See Also

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