>the same thing?
No, cin.getline is for C-style strings. The kind that use arrays and a nul termination character '\0'. The string class has its own overloaded getline function. Since it requires std::strings, it makes sense to be declared in <string>:
Code:
#include <iostream>
#include <string>
int main()
{
string s;
cout<<"What's your name: ";
if ( std::getline ( std::cin, s ) )
std::cout<<"Hello, "<< s <<'!'<<std::endl;
}
As opposed to the C-string equivalent which is declared as a part of std::istream and can be reached from <iostream>:
Code:
#include <iostream>
int main()
{
char s[100];
cout<<"What's your name: ";
if ( std::cin.getline ( s, sizeof s ) )
std::cout<<"Hello, "<< s <<'!'<<std::endl;
}