代碼如下。我想讓它在輸入-1
時退出循環。或者我想找到一個更好的解決方案,如果有的話。爲什麼我的for循環不工作?
if (aa == "hours") {
std::cout << "Please enter hours below: (Type -1 to stop)" << std::endl;
for(x; x > -1; x++) {
std::cin >> hours[x];
std::cout << hours[x];
}
}
請向你的問題添加什麼是你看到的行爲,爲什麼這不是你所期望的。 –