早些时候我发布了一个关于cin跳过输入的问题,我得到了刷新和使用的结果istringstream,但现在我尝试了所有可能的解决方案,但它们都没有工作.
这是我的代码:
void createNewCustomer () {
string name, address;
cout << "Creating a new customer..." << endl;
cout << "Enter the customer's name: "; getline(cin, name);
cout << "Enter the customer's address: "; getline(cin, address);
Customer c(name, address, 0);
CustomerDB::addCustomer(c);
cout << endl;
}
Run Code Online (Sandbox Code Playgroud)
但我仍然得到同样的东西,跳过输入,当它确实需要输入时,它需要它们并且名称中的存储空白,并且在地址中它采用我在名称中写的但是从第二个字母到结尾
我的代码出了什么问题?
我尝试了cin.ignore(),cin.get()和cin.clear()所有的人一起,独自一人,没有一次成功
编辑:
main.cpp中的main方法mainMenu()只调用
void mainMenu () {
char choice;
do {
system("cls");
mainMenuDisplay();
cin >> choice;
system("cls");
switch (choice) {
case '1': …Run Code Online (Sandbox Code Playgroud)