【发布时间】:2013-10-01 15:45:34
【问题描述】:
我正在尝试评估单个字符:
bool repeat = true;
while (repeat)
//code
char x;
cout << "Would you like to tansfer another file? Y/N ";
cin >> x;
if (x == 'y' || x == 'Y')
repeat = true;
if (x == 'n' || x == 'N')
repeat = false;
else
throw "Input error";
我不断收到输入错误作为我的控制台输出。任何想法为什么?我无法让 while 循环重复。
【问题讨论】:
标签: c++ while-loop boolean