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;
}
#include <string>
string s;
getline(cin, s);
Code Example |
---|
Cpp :: switch case with string c++ |
Cpp :: how to convert int to string c++ |
Cpp :: default access modifier in c++ |
Cpp :: delete last char of string c++ |
Cpp :: how to compare lower case character to uppercase cpp |
Cpp :: c++ extend class |
Cpp :: calculator c++ |
Cpp :: allow cross origin |
Cpp :: fiunction in c++ |
Cpp :: appending int to string in cpp |
Cpp :: how to convert int to std::string |
Cpp :: tuple c++ |
Cpp :: latex table landscape |
Cpp :: elements of set c++ |
Cpp :: how to check if a number is prime c++ |
Cpp :: fstring from float c++ ue4 |
Cpp :: how to get an element in a list c++ |
Cpp :: segmented sieve cpp |
Cpp :: initialize 2d vector |
Cpp :: string to char* |
Cpp :: on component begin overlap c++ |
Cpp :: append string cpp |
Cpp :: tolower funciton in cpp |
Cpp :: are strings mutable in c++ |
Cpp :: is power of 2 |
Cpp :: palindrome checker in c++ |
Cpp :: Reverse Level Order Traversal cpp |
Cpp :: bee 1002 solution |
Cpp :: vector to string cpp |
Cpp :: c++ string find example |