Wednesday 29 January 2014

Explain strlen() function.

strlen() function-It counts number of characters in a string.
Syntax
l=strlen(string)   ,where l reads the count of characters

Write a program to read a string through keyboard.Determine length of the string.

#include<stdio.h>
#include<conio.h>
main()
{
    char string[10];
    int string,l;
    printf("Enter the string:");
    gets(string);
    l=strlen(string);
    printf("Entered name is %s and its length is %d",string,l);
}
Output
Enter the string:
Rohini
Entered string is Rohini and its length is 6

No comments:

Post a Comment