if I input n as 5, it is reading only till first 4.
My code is same as shown is video
Code not working
But why should I do that. I am just doing the 2D version of this code https://ide.codingblocks.com/s/237282
This is a common problem, and it happens because the cin operator doesn’t read the newline character of your input, so when you issue the command cin.getline() then cin finds the newline character and gives you that as a line.
thats why using cin.get() to read that newline
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.