Problems related to getline and get

i am not be able to understand the 8th and 10th line of code.i have shared the code https://ide.codingblocks.com/s/312599

hi @vikash3303
cin ignores the ‘\n’ character
so when we do cin >> n, ‘\n’ character is not taken in input and it keeps sitting in the input buffer
Then when we do cin.getline(), it will read till it encounters ‘\n’ character, which happens to be present in the input buffer already, so it does not take any input and stops after that only
to avoid this, we do cin.get() which takes input a single character, to consume the stray ‘\n’ character that was there in the input stream

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.