why cin.get and cin.getline() are used here
Confused with cin.get
cin.get() is used to consume ‘\n’
which is present at end of first line
and cin.getline() is use to take input string with whitespaces also
what will happen if we not consume it
cin.getline() take this ‘\n’
and one less string will be taken by cin.getline() as one string is “\n”;
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.