C++ Program to Find Length of String

In this program, you'll learn to find length of a string.



Source Code
#include<iostream>
using namespace std;

int main()
{
    char s[20];
    int i=0, len=0;

    cout<<"Enter the string\n";
    gets(s);

    while(s[i] != '\0')
    {
        len++;
        i++;
    }
    cout<<"Length of given string = "<< len;
    return 0;
}
Output
Enter the string
Welcome to CPP
Length of given string = 14