cplusplus.com > reference > cstring > strlen |
strlen
<string.h> |
cplusplus.com |
Return string length.
Returns the number of characters in string before the terminating
null-character.
Parameters.
Return Value.
The length of string.
Portability.
Defined in ANSI-C.
Example.
/* strlen example */
#include <stdio.h>
#include <string.h>
int main ()
{
char szInput[256];
printf ("Enter a sentence: ");
gets (szInput);
printf ("Sentence entered is %u characters long\n",strlen(szInput));
return 0;
}
Output:
Enter sentence: just testing
Sentence entered is 12 characters long
See also.
strcmp,
strcspn,
strchr,
strrchr