how cin.get() is working?
and why i am getting n-1 strings as input without using cin.get()?
https://onlinegdb.com/KhMeWqRna
Hello @hittasehgal,
cin.get() is used to take extra whitespaces from input.
In our case, after taking input n there is an extra white space left.
-
If we remove cin.get(), then while taking input only the first n-1 strings would be taken as input, the first string would be whitespace, and the rest of the strings would be taken from the input.
-
If we take cin.get() into consideration, then it would first remove the whitespace and, then we could easily take n strings as 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.