C++ Program to find length of string using strlen function


In this program, You will learn how to find length of string using strlen function in C++.


int len = strlen(str);


Example: How to find length of string using strlen function in C++

Run it Now
#include<iostream>
#include<cstring>
using namespace std;

int main() {

    int len;
    char str[100];

    cout << "Enter a string :";
    cin.getline(str, 100);

    len = strlen(str);
    cout << "\nThe Length of string :" << len;

    return 0;
}

Output:

Enter a string :C++ Programming
The Length of string :15