I'm trying to use a getline function in my program. I have the correct cout function but when I try and enter my input the program keeps wanting me to enter a couple of times and then that's what comes out. I'm very confused on what I'm doing wrong in my program. This is what I have.
#include <iostream>
#include <cstring>
int main()
{
using namespace std;
string str2;
cout<<"Enter a line of input for str2: ";
getline (cin, str2);
cin>>str2;
cout<<"Contents of str2: ";
cout<<str2<<endl;
return 0;
}