So, I was just starting C++, and I have a problem. I declared a string variable and all that, but when I have input give the variable a value, then try to display it, it only shows the first word of the sentence.
#include <iostream>
#include <string>
using namespace std;
using std::string;
int main()
{
        string answer;
        cout << "Give me a sentence and I will repeat it!";
        cin >> answer;
        cout << answer;
        return 0;
}
For example, I entered "Yay it worked!", and it outputted "Yay"
 
    