Here you will get C++ program to discover the length of a string without utilizing library work.
We emphasize through the string until the invalid character ‘\0’ is experienced and increment a counter factor for every cycle.
At long last print the counter factor, it contains the length of the string.
Program
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
char a[30];
int i;
cout<<"Enter a string:";
gets(a);
for(i=0;a[i]!='\0';++i);
cout<<"\nLength of the string '"<<a<<"' is "<<i;
return 0;
}
Output–
Enter a string:hello hi
Length of the string ‘hello hi’ is 8