consider a string like string s = "xyz123".
for(char ch : s)
cout<<ch;
and stringstream like
char ch;
stringstream ss(s);
while(ss>>ch)
cout<<ch;
They both give the same solution. Is there any case where the two behave differently? When should each be used.