Header file:
string.h
Synopsis:
size_t strlen(char *str);
Description:
Returns length of string str.
strlen function C example:
#include<stdio.h>
#include<string.h>
int main() {
char str[100];
int len;
strcpy(str, "mastering-c.blogspot.com\n");
len = strlen(str);
printf("Length of the given string: %d\n", len);
return 0;
}
#include<string.h>
int main() {
char str[100];
int len;
strcpy(str, "mastering-c.blogspot.com\n");
len = strlen(str);
printf("Length of the given string: %d\n", len);
return 0;
}
Output:
jp@jp-VirtualBox:~/cpgms/chap5$ ./a.out
Length of the given string: 25
Length of the given string: 25
No comments:
Post a Comment