Getline using std::string vs getline using C-style strings

I have been always fairly confused when dealing with input streams, reading characters, words, or whole lines of text. I was not sure which of the function to use, and why.

One of the things that confused me most was, that there are two getline() functions and it was not so obvious which to use when.

But, it is pretty simple.

The global getline() function works with C++ std::string objects. The istream.getline() work with C-style strings, which are arrays, or pointers to chars.

std::string s;
char carr[100];

getline(std::cin, s); // read line to c++ std::string
std::cout << s << "\n";

std::cin.getline(carr, 100); // read line to c-style string
std::cout << carr << "\n";

That is all there is to it.