#include <string>
std::string input;
std::cin >> input;
ผู้ใช้ต้องการป้อน "Hello World" แต่cinล้มเหลวที่ช่องว่างระหว่างสองคำ ฉันจะcinลงมือทำทั้งหมดได้Hello Worldอย่างไร
จริง ๆ แล้วฉันกำลังทำสิ่งนี้กับ structs และcin.getlineดูเหมือนจะไม่ทำงาน นี่คือรหัสของฉัน:
struct cd
{
std::string CDTitle[50];
std::string Artist[50];
int number_of_songs[50];
};
std::cin.getline(library.number_of_songs[libNumber], 250);
นี่ทำให้เกิดข้อผิดพลาด ความคิดใด ๆ
libraryเพื่อให้เป็นที่ชัดเจนว่ามันเป็นของประเภทcd
getline intแน่นอนว่าล้มเหลว