I am new to programming and I have some questions about the get() and getline() functions in C ++.
My understanding of two functions:
The getline() function reads an entire line and uses the newline character passed by the Enter key to mark the end of the input. The get() function is very similar to getline() , but instead of reading and discarding a newline, get() leaves that character in the input queue.
The book (C ++ Primer Plus) that I am reading suggests using get() over getline() . My confusion is that it is not getline() safer than get() , since it terminates the line with '\n' . On the other hand, get() will just hang a character in the input queue, which can cause problems?
source share