At 4:42, I didn’t get how we used cin.get() to read the character and then cin.get() inside the loop to resume from the hello_world string. Please explain.
Character Strings - Largest String
hello @yajurkhurana
when we press enter after giving integer then \n will remain there in the buffer.
and we will read the same \n as string in the first iteration of loop due to which we will get one output less than expected (becuase we counted \n as one string)
so to avoid this we have added cin.get()(it will read \n that is there after giving integer in input).
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.