string s;
getline(cin,s);
Using getline() will help you.
Example:
int main()
{
std::string name, title;
std::cout << "Enter your name: "; //Name: Robert De Niro
std::getline(std::cin, name);
std::cout << "Enter your favourite movie: "; // title: The Irishman
std::getline(std::cin, title);
std::cout << name << "'s favourite movie is " << title;
}
std::string str;
std::getline( std::cin, str);
#include <string>
string s;
getline(cin, s);