Write a Program to Find the Length of the String Without using strlen() Function 

C++// C++ Program to find the length of a string without using // strlen() #include <cstring> #include <iostream> using namespace std; int main() { string str = "GeeksforGeeks"; int length = 0; for (int i = 0; str[i] != '\0'; i++) { length++; } cout << "The length of the string is: " << length << endl; return 0; }

Output

The length of the string is: 13

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *