c++ - Wrong type of input
问题描述
I have the code below, so basically my problem is: when someone input a character like 'a', it will pop a message that requires a re-input
I tried using the ASCII:
if (a >= 97 && a <= 122)
but it still didn't work
double a;
cin >> a;
if (a >= 'a' && a <= 'z')
{
cout << "Wrong input, please re-input a: " << endl;
cin >> a;
}
cout << a;
I expect it to pop the message to re-input but the actual output is always 0
no matter what character I input
解决方案
推荐阅读
- javascript - 提交表单时出现未定义的错误
- c# - 将按钮添加到 WPF 中的非客户区
- angular6 - 使用 angular6 将多个值推入数组会产生错误
- android - 为什么 MotionEvent.getx() 在 onTouchEvent 和 onDraw 中的结果不一样?
- r - 绘制作为星期几和一天中时间函数的买入比率直方图
- algorithm - 关于Min Max Heap DeleteMin的时间复杂度
- python - 如何使用 python 访问当前打开的浏览器 URL
- dart - 如何在颤动中执行 VoidCallback
- gitlab - 在 Xcode 中推送到 gitlab 后项目为空
- c++ - 编译程序时遇到 c++ Visual Studio 编译器错误“htonf”