A little more explanation of the code used in this vide

what is the use of cin.get() here before the loop?also can I get a bit more knowledge about cin.getline()

hello @Nitin-Bhattacharyya-2319140631658033

  1. cin.get()
    It is used to read a word or character.
    It terminates on encountering whitespace or endline charater (’\n’)
  2. cin.get(char_array,number_of_characters,delimiter)
    To read characters including special characters like ’ ', ‘\n’ and ‘\t’.
  3. cin.getline(char_array,max_Size,delimiter)
    It is used to read a sentence or a paragraph.
    It terminates on encountering endline character.
    It also reads the whitespace.

Difference?

  1. The get() function is much like getline() but rather than read and discard the newline character, get() leaves that character in the input queue.
  2. get() leaves the delimiter in the queue thus letting you able to consider it as part of the next input.

Explanation:
cin.getline() reads input up to ‘\n’ and stops

cin.get() reads input up to ‘\n’ and keeps ‘\n’ in the stream

when you say delimiter you mean \n or white space right?also then why are we using cin.get() here?
int n;
cin>>n;
cin.get();
for(int i=0;i<n;i++)
{
cin.getline(a[i],1000);
}
for(int i=0;i<n;i++)
{ cout<<a[i]<<endl;}

what you are trying to do with this code ?
i mean for which question you have written this code ?

This isn’t a code I have written,it was written by Prateek sir in a video “Read a list of strings and store them in a 2d Character array”. I am trying to understand it.

cin.get() is used for consuming some extra element after taking input n .

Also
Say char ch
Then both cin.get(ch) and ch=cin.get() are same right or is there any difference even though it seems to work the same?

Also
Say char ch
Then both cin.get(ch) and ch=cin.get() are same right or is there any difference even though it seems to work the same?

yes both will work same .

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.