This function counts the number of characters present in a string.
Hence, strlen() function return always numeric value.
syntax:
strlen("Any_string");
example:
strlen("C Program");
It return : 9
The following program illustrated the uses of strlen() function as:
/*c program to illustrate the use of strlen function*/
#include<stdio.h>
int main()
{
int len;
char str[40];
printf("Enter any string : ");
gets(str);
len = strlen(str);
printf("%s = %d Characters",str,len);
getch();
return 0;
}
The output of above program would be:
Related program:
Hence, strlen() function return always numeric value.
syntax:
strlen("Any_string");
example:
strlen("C Program");
It return : 9
The following program illustrated the uses of strlen() function as:
/*c program to illustrate the use of strlen function*/
#include<stdio.h>
int main()
{
int len;
char str[40];
printf("Enter any string : ");
gets(str);
len = strlen(str);
printf("%s = %d Characters",str,len);
getch();
return 0;
}
The output of above program would be:
Figure: Screen shot for illustrate of strlen() function |
Related program:
0 komentar:
Post a Comment