// getline in C++ // This program shows how to read a line of data either into // a c++ string or into a C-style array of char. // The two getline methods are very different // Both can work with an arbitrary istream (not just cin). #include #include using namespace std; int main() { string s; if ( getline( cin, s, '\n') ) cout << s << endl; char buf[1024]; if( cin.getline( buf, 1024 ) ) cout << buf << endl; }