Strings first video string class

please explain compare function in strings.

How s1.begin() works
and why we write it!=s1.end() in loop as it is not included so how can last element be checked.

and also please explain
for ( char c : s1 )

hello @tejuschaturvedi0

s1.begin() gives us iterator that points to the start of the given string.
s.end() gives us itertor that points to address next to last character.

s.end() is not pointing at last character instead it is pointing to address that is next to last character.

we call it for each loop(it is same as iterating string)
here in c u will get one character of string one by one.

1 Like

Means it doesn’t need any incrementor and breaking condition.and it takes next index of string every time.

yeah right… . . . . ., we dont have to mention any incrementor or any breaking condition

1 Like

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.

Where I have to rate it . The link is taking me to my dashboard where my performance graph is showing.

try to click again