0
I am trying to find the string length using for loop but there is some error
#include <iostream> #include<string> #include<cstring> using namespace std; void harsh(){ char text[100]; cin>>text; int a=0; int i=0; for( i=0;text[i]!='\0';i++) { a++; cout<<"\nstring length is"<<a; } } int main() { harsh(); return 0; } Output: String length is 1 String length is 2 String length is 3 String length is 4 String length is 5 Input: There Why this is happening Help me!! https://code.sololearn.com/cp75TPia7YMB/?ref=app https://code.sololearn.com/cp75TPia7YMB/?ref=app
5 Answers
+ 2
Thank you so much it works
+ 2
Thank you
+ 2
Thank you now my concept is clear
+ 2
Thank you i will use this in my projects
+ 1
Yes i noticed that but why you don't use curly braces