Reading strings

In the following code:
int main()
{
char a[][];
int n;
cin>>n;
cin. get():
for(int i=0;i<n;i++)
cin. getline(a[i],10);
return 0;
}

I couldn’t understand what is the need of writing cin. get() after cin>>n
Please explain this concept in detail because I am an average student

cin. get() is used for accessing character array. It includes white space characters. Generally, cin with an extraction operator (>>) terminates when whitespace is found.

The first cin>>n; reads a single word, skipping over any leading space characters, and stopping when it encounters a space character (which includes the end of the line).

The second cin.get(a,256);cin.get(); reads a whole line, then consumes the end-of-line character so that repeating this will read the next line. cin.getline(a,256) is a slightly neater way to do this.

If u run the code without cin.get()
then u`ll be able to take just n-1 inputs

I am sorry but I couldn’t understand anything

see with
cin >> n
u just read one character the i/p is terminated as soon as white space or escape character is encountered.
the space or ‘\n’ character is added to the stream
hence cin.get() helps to read just one character ie the escape character so that cin.getline(a[i],10) can take the further input string

now we need to read multiple space separated string from the user so we use cin.getline(a[i],10 )

read this answer if u are still unable to understand

read independently about
cin.get == https://www.geeksforgeeks.org/cin-get-in-c-with-examples
cin.getline()
cin >> n

Thank You Mam. Mam I have your WhatsApp number. So can I ask my queries through Whatsapp if any such situation arises?

You can at any point ask any doubt on the ask doubt section

you`ll get help from any TA
or u can ask it in the whatsapp CB group some of ur batch mates will answer

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.