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
strlen(str)
Length of String In C++
str.size();
str.length() c++
Both Use in C++. Here str is a string variable.
Output:
=====================================
Visit - www.nerdutella.com
=====================================
Enter An Any String:
c++ programming
Lenth Of The Given String Given Below Is
15
need an explanation for this answer? contact us directly to get an explanation for this answer