这里的代码段是我的工作:CIN是跳过线
std::cout << "Enter title of book: ";
std::string title;
std::getline(std::cin, title);
std::cout << "Enter author's name: ";
std::string author;
std::getline(std::cin, author);
std::cout << "Enter publishing year: ";
int pub;
std::cin >> pub;
std::cout << "Enter number of copies: ";
int copies;
std::cin >> copies;
这是它运行时从本节的输出(加引号):
"Enter title of book: Enter author's name":
怎么办我解决这个问题,以便我可以输入标题?
(当前)两个答案提供了什么极有可能是解决问题的方法,但问题是缺少[MCVE的完整性要求(http://stackoverflow.com/help/mcve),不能与回答肯定。 [cin和函数getline跳过输入]的 – user4581301
可能的复制(http://stackoverflow.com/questions/10553597/cin-and-getline-skipping-input) – Mykola