3.2.37. strlen

Returns the length or the specified string.

Syntax

unsigned long strlen (str1)
char *str1;

where:

str1

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

Description

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.

Rules

  • Strings are assumed to be NUL terminated.

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

Example

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

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

See Also

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