strlen(3) — Subroutines
NAME
strlen − Finds length of string
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <string.h> size_t strlen(
const char ∗s);
PARAMETERS
sSpecifies the string.
DESCRIPTION
The strlen() function returns the number of bytes in the string pointed to by the s parameter. The string length value does not include the string terminating null character.
Note
If you pass a NULL pointer as the const char ∗ parameter to the strlen function, the function generates a segmentation violation. To avoid the segmentation violation and cause the function to return zero, change the NULL pointer treatment for the process before issuing the call to the strlen function, as follows:
1.Include the system header file sys/uswitch.h.
2.Call the uswitch function, as described in the uswitch(3) reference page.
The following program illustrates this procedure:
#include <stdio.h>
#include <sys/types.h>
#include <sys/uswitch.h>
main()
{
size_t retval;
int uswitch_val;
uswitch_val = uswitch(USC_GET,0);
uswitch(USC_SET, uswitch_val | USW_NULLP);
retval = strlen(NULL);
NOTES
AES Support Level:
Full use.
RETURN VALUES
Upon successful completion, the strlen() function returns the number of characters in the string to which the s parameter points. Otherwise, (size_t)-1 is returned, and errno is set to indicate the error.
RELATED INFORMATION
Functions: string(3), uswitch(3), wcslen(3).