Find length of string - C++ Program

Q. Write a C++ program to find the length of the string.

Answer:

Following program is displaying the length of the string using strlen() library function. This function is used to count the length of the string.

#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;
int main()
{
        char str[100];
        cout<<"\n Enter a String : ";
        gets(str);
        cout<<"\n Length of the String is : "<<strlen(str);  
        //strlen() is a library function, used to count the length of the string.
        return 0;
}


Output:

find length