基本c++输入问题
Basic C++ Input Issue
在(cin <<)输入),永远不会用到if语句。
我在while循环之外运行代码,它似乎可以工作。有人能帮忙吗?
#include <iostream>
using namespace std;
int main() {
int input = 0;
bool stop = false;
while(!stop) {
while( input == 0 ) {
cout << "Enter the radix (-1 to exit): ";
cin >> input;
if (input == 2) {
cout << "foo";
} else {
cout << "bar";
}
}
}
}
谢谢!
编辑:固定!显然我忘了"冲"牌了。所以我需要一个"count <<"结束"after"cin <<输入"。
考虑你的循环。你有
while(!stop)
{
//do stuff but never change stop
}
所以它永远不会退出循环
相关文章:
- cpp二进制搜索问题,计算给定数组中输入元素的出现次数
- 编写时C++中的输入重定向问题
- 输入std::数组时出现问题
- 我试图制作一个程序,要求用户输入问题和答案,但程序循环不正确
- 打印时有二叉树问题.用户输入不打印任何内容
- 用户输入字符串的文件附加问题..C++
- 我无法在Visual Studio代码中使用CIN输入答案,它说输入您的年龄,但它说只读文本编辑器如何解决这个问题?
- 遇到此问题时遇到困难:允许用户输入数组的值并使用 for,而循环也输出输入的最大数字
- C++模板编程设计问题 - 根据输入文件返回不同的类型
- 我应该如何在C++中使用结构体解决输入失败的问题?
- 我遇到使用 c++ 逐行读取输入文件的问题
- 在 2D 矢量中获取多个输入时出现问题
- 不确定出了什么问题(字符串输入)
- 在C++中读取 unicode 输入时出现问题
- 函数,从问题中获取输入,并在主函数中使用该输入
- c++中重载输入运算符的问题
- 通过终端在文件中输入时检测EOF(文件结束)时出现问题
- C ++回测问题:如何检查构造函数在假定失败时是否失败(给定输入的无效参数)
- 从标准输入读取多个类型时出现问题
- visual studio 2008 - c++问题输入