(Note All the getline() functions below are designed to return text from a File or cin — actually a one-way stream. Inapplicable to sockets.)
1) Most documentations mention the older c-str-based istream::getline() http://www.cplusplus.com/reference/istream/istream/getline/. However,
2) http://www.cplusplus.com/reference/string/getline/ is another getline(). Unlike the c-str versions of istream::getline() method, this std::string version is implemented as free function instead of member function.
This version is more modern. C++11 added new features to this free function, but didn’t bother with (1)
Between these 2 getline() functions,
– One uses c-str; the other uses c++ string class.
– One is a member function; the other a free function
– both require streams, therefore unusable in C.
http://www.learncpp.com/cpp-tutorial/132-input-with-istream/ discusses both.
There’s an IKM question on the member function (1).
3) http://www.gnu.org/software/libc/manual/html_node/Line-Input.html describes a prehistoric ANSI-C standard library function — not using string Class or istream Class. http://crasseux.com/books/ctutorial/getline.html is a short and sharp tutorial on it.
——- philosophically ——-
We can’t assume the most “everyday” programming tasks in a major language are always well-covered online — completely covered, with the confusing details pointed out. Reading a text file is basic but supported by a confusing bunch of alternatives, all named getline().
http://www.augustcouncil.com/~tgibson/tutorial/iotips.html does describe pitfalls of istream::getline()