Calculate the length of the string
strlen( ) : This function will calculate the length of the string.by length,we means the number of characters present in the string,excluding the NULL character.
The general form is ,int strlen(char [ ])
Consider the following ,
#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
{
char s[50];
int len;
clrscr( );
printf("\nEnter the String :");
scanf("%s",s);
len=strlen(s);
printf("\nLength=%d",len);
getch( );
}
output :
Enter the string : ajay
Length = 4
Comments
Post a Comment