+ 17
Rahul Kumar getline() is a standard library function in C++ and is used to read a string or a line from input stream. It is present in the <string> header.
If you're using getline() after cin >> something , you need to flush the newline character out of the buffer in between. You can do it by usingcin.ignore() . It would be something like this: string messageVar; cout << "Type your message: "; cin.ignore();getline(cin, messageVar);



