C++ 获取用户输入
我在这条线上有个问题C++ 获取用户输入,c++,input,C++,Input,我在这条线上有个问题 cout << "Please input how many hours your pool pump ran this month: "; cin.get(hours,15); cin.ignore(80,'\n'); cout您应该这样做: int hours = 0; cout << "Please input how many hours your pool pump ran this month: " cin >> hou
cout << "Please input how many hours your pool pump ran this month: ";
cin.get(hours,15);
cin.ignore(80,'\n');
cout您应该这样做:
int hours = 0;
cout << "Please input how many hours your pool pump ran this month: "
cin >> hours;
int小时=0;
不能>小时;
有关代码未按预期工作的原因,请查看cin.get()
和cin.ignore()
文档: