C++ Program to Find The Length of a String Without Using Strlen Function

Problem:- Write A C++ Program To Find The Length Of Any String or How to Find the length of String In C and C++? or C++ Program to Find Length of String Without Using Library Function or C++ program to find Length of String or C++ Program to Find the Length of a String or C++ program to Find Length of String without using strlen or calculate length of a string without using standard library or C program to find the length of a String without using function strlen() or Returning number of characters without using strlen or C Program to Find the Length of a String without using the Built-in function or Program to find the length of a string taken from user without using inbuilt function.

Check This:- Hacker rank solution for Strings, Classes, STL, Inheritance in C++.

Logic:- We have an inbuilt function to find length or size of the string. In this problem, I count string character from start to end ( '\0' ) and print the total number of count. we can either use a count variable and increase the count by 1 in each iteration but no need I an using an array index and with the help of an array I print the last index of an array. we can calculate a length of a string in C/C++ both functions are given below.

Length of String In C


Length of String In C++

str.length() c++

Both Use in C++. Here str is a string variable.

Also Check:- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.

Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date for a new post or if you have any Query you can ask there with lots of coders also suggest to your Friends to join and like our page.


using namespace std;
 int main()
/*Visit - www.programmingwithbasics.com*/
    cout<<"\nVisit - www.programmingwithbasics.com";
  char a[50];
  int i;
  cout<<"Enter An Any  String:\t";
  cout<<"\nLenth Of The Given String Given Below Is\n\n";
  return 0;



No comments:

Post a Comment