Learning C
C Function References
C Useful Resources
Selected Reading
Copyright © 2014 by tutorialspoint
|
C - strlen function
Synopsis:
#include <stdio.h>
int strlen(char *src );
|
Description:
The strlen function calculates the length, in bytes, of src. This calculation does not include the null terminating character.
Return Value
The strlen function returns the length of src.
Example
#include <stdio.h>
int main() {
char string1[20];
char string2[20];
strcpy(string1, "Hello");
strcpy(string2, "Hellooo");
printf("Length of string1 : %d\n", strlen( string1 ));
printf("Length of string2 : %d\n", strlen( string2 ));
return 0;
}
|
It will proiduce following result:
Length of string1 : 5
Length of string2 : 7
|
|
Advertisements
|
|
|