Could not understand cin.get()

Could not understand why cin.get() was used to take the input of the integer value/

Hey @ayusdas2000


Have a look at this

Understood what you sent but could not find out why it was specifically used to input the integer in this video.

@ayusdas2000
Can you please tell me the time in the video where this happened ?
Thanks.

time stamp is 01:01 i am unable to understand why cin.get() was used to consume the extra space after \n as said by prateek bhaiya.

@ayusdas2000
So what happens is
after you cin>>n;
the next input in buffer is ‘\n’
if you then do getline(cin,string)
the string will end up storing ‘\n’
So we use cin.get() to consume ‘\n’ in input buffer before we can start taking string inputs