C++ Program to Find Length of String

« Previous Program Next Program »

Find String Length in C++

To find the length of the string in C++ programming, you have to ask to the user to enter the string and then find the length the that string using function strlen() of string.h library and display the length value of the string on the output screen as shown here in the following program.

C++ Programming Code to Find Length of String

Following C++ program ask to the user to enter a string to find the length of that string using strlen() function, then display the result on the screen:

/* C++ Program - Find Length of String */
void main()
	char str[20];
	int len;
	cout<<"Enter a string : ";
	cout<<"Length of the string is "<<len;

When the above C++ program is compile and executed, it will produce the following result:

C++ program find length of string

Same Program in Other Language

You may like the same program in other programming languages:

« Previous Program Next Program »


Quick Links
Signup - Login - Give Online Test