Find Length of String in C++
Here you will learn the source code to find length of string in C++ programming language. This program can be done by using strlen built-in function and without using strlen function. Here we will be using the strlen function to find the length of a string.
How to Find Length of String in C++
1 2 3 4 5 6 7 8 9 10 11 12 13 | #include<iostream> #include<string.h> using namespace std; int main() { char st[100]; int len; cout<<"\n\tEnter any string to find length : "; gets(st); len = strlen(st); cout<<"\n\n\tLength of string is = "<<len; return 0; } |
Output
Enter any string to find length : www.coderevise.com
Length of string is = 18
Check out our other C++ programming Examples