#include <iostream>
#include <string>
using namespace std;
int main()
{
string str;
cout << "Please enter a string: ";
getline(cin, str);
cout << "You entered: " << str;
return 0;
}
Posted inC++
#include <iostream>
#include <string>
using namespace std;
int main()
{
string str;
cout << "Please enter a string: ";
getline(cin, str);
cout << "You entered: " << str;
return 0;
}