C – strlen() function
- · strlen( ) function gives the length of the given string.
- · strlen( ) function counts the number of characters in a given string and returns the integer value.
- · It stops counting the character when null character is found. Because, null character indicates the end of the string in C.
Syntax : int strlen(string);
/* PROGRAM TO FIND LENGTH OF THE GIVEN STRING */
#include<string.h>
main()
{
char
str[50];
int n;
clrscr();
printf("\nEnter
a string:");
gets(str);
strlen(str)
printf("\n
STRING LENGTH IS:%d", strlen(str));
}
No comments:
Post a Comment