20:59 of this video , why didnt we require to take cin.get()

why didn’t prateek take cin.get() to consume the ‘\n’ after inputting the key, so that we can input reversal without error

hi @Rythmrana
for inputting strings, u can directly take input like that…
say,

string str;
cin>>str;

no i meant , for taking input a string after inputting an integer, we use first have to consume that \n by using cin.get(), however prateek bhaiya didnt use it and still his code worked fine. why did this happen?

There is no need of what u are saying consuming \n… It’s just the way of entering the input… instead of writing the string in new line u can even write it after giving space after integer…

so why did he use cin.get() to consume the \n in the code after inputting int n. Please look int the video he used it after inputting the ‘n’ integer variable to consume the \n, however didnt use it after inputting key.

okay, sorry i got it now. my mistake.

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.