Please explain the difference between get( ) and getline( ) function. I’m confused between the two.
Get( ) and getline( ) function
https://stackoverflow.com/questions/26873401/difference-between-cin-get-and-cin-getline#:~:text=The%20getline()%20function%20reads,character%20in%20the%20input%20queue.
Please refer to this link.
https://ide.codingblocks.com/s/481887 - In line 45 & 46, if I’m using getline, I’m getting wrong ans & when I’m using cin, I’m getting right ans. Will you please let me know why?
hello @gambhirrahul0
u have reopend the doubt.
pls use cin.get() to consume \n just before the while loop and then u can use getline
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.