strlen()

Computes the length of a character array.

  #include <string.h>
  
  size_t strlen(const char *s);    
Parameter

s

A pointer to the string to evaluate.

Remarks

This function computes the number of characters in a null-terminated character array pointed to by s. The null character ( '\0') is not added to the character count.

This function's behavior is undefined if the character string pointed to by s is not null terminated.

The function returns the number of characters in a character array not including the terminating null character.

This facility may not be available on some configurations of the EWL.

Listing: Example of strlen() Usage

#include <string.h>

#include <stdio.h>

int main(void)

{

char s[] = "antidisestablishmentarianism";

printf("The length of %s is %ld.\n", s, strlen(s));

return 0;

}

Output:

The length of antidisestablishmentarianism is 28.