C Program to Find Length of String Using Library Function
Find Length of String Using Library Function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include<stdio.h> #include<string.h> int main() { char str[100]; int len; printf("\nEnter the String : "); gets(str); len = strlen(str); printf("\nLength of Given String : %d", len); return(0); } |
Explanation of Program :
We need to find the length of the string using library function provided by C Programming.
1 |
len = strlen(str); |
strlen() function will evaluate the length of the string and return the string length (i.e integer value).
1 |
#include<string.h> |
We need to include string.h header file in order to use string manipulation functions in c program.
[box]
Functions Required => strlen() : String Function for Computing Length
[/box]