Syntax error in using iterators it shows that i was not declared

for(auto i = s.begin();i!=s.end();i++)
{
	cout<<(*i)<<endl;
}

when i did this it gives me error that i is not declared in this scope

@mananrasool2 hey it is not showing any error . i think you have forgot to declare the header file in which string class come . see this code

#include <bits/stdc++.h>
using namespace std;
int main() {
string s = “Hello World!”;
for(auto i = s.begin();i!=s.end();i++)
{
cout<<(*i)<<endl;
}
}

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.