fastread homefastrread library fastread menu

C++ : Find the Length of a String

Tutorial by:Manisha Dubey      Date: 2016-06-18 05:06:39

❰ Previous Next ❱

You can use standard library function strlen() to find the length of a string but, this program computes the length of a string manually without using strlen() funtion.

Source Code to Calculate Length of a string without using strlen() Function

#include <iostream>
#include <cstring>
using namespace std;
int main()
    char s[1000],i;
    cout << "Enter a string: ";
    cin.getline(s, 1000);
    for(i=0; s[i]!='\0'; ++i);
    cout << "Length of string: " << i;
    return 0;


Enter a string: Programiz
Length of string: 9

❰ Previous Next ❱


Submit Your Thought, Tutorial, Articls etc.

Submit Your Information India's Number one online promotion website