Hello, I'm just learning C++, and I was working with C++-style strings when something stumbled me.
Basically, what it's supposed to do is add 'please.' to the end of the phrase. However, this code always cuts out the first word.Code:#include <iostream> using namespace std; int main() { string szOriginal, szPlease; cout<<"Please type a message for me to reprint with the word 'please' at the end!\n"; cin>>szOriginal; getline(cin, szOriginal, '\n'); szPlease = szOriginal + szPlease; cout<<szPlease; szOriginal[0] = '\0'; szPlease[0] = '\0'; cin.get(); }
e.g. "Give me some toast" becomes " me some toast please."
Assistance would be appreciated!