C++ Program to Find the Length of a String

  • How to find length of a string without using any standard library functions in C++.
  • C++ program to calculate string length using while loop.

C++ program to find the length of a string

#include <iostream>

using namespace std;
int main(){
    char str[1000];
    int length = 0;
    cout << "Enter a string\n";
    cin.getline(str, 1000);

    while(str[length] != '\0'){
    cout << "Length of String is : " << length << endl;
    return 0;
Enter a string
Length of String is : 15