這裏的代碼段是我的工作: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