📜  在 cpp 中读取字符串时包含空格 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:55.264000             🧑  作者: Mango

代码示例1
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;
}