C++ Program to Find the Length of a String

#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    char str[200];
    int len=0, i=0;
    cout<<"Enter the String: ";
    gets(str);
    while(str[i])
    {
        len++;
        i++;
    }
    cout<<"\nLength = "<<len;
    cout<<endl;
    return 0;
}

OUTPUT:

String before modification: String@123!!
String after modification: String

Sharing Is Caring

Leave a Comment