gpt4 book ai didi

c++ - 为什么对 isspace() 的调用永远不会返回 true?

转载 作者:太空宇宙 更新时间:2023-11-04 14:39:22 24 4
gpt4 key购买 nike

<分区>

可能这已被问过 100 次,但我找不到或无法提供解决方案。一切(据我测试)都被识别,只有按下空间不起作用。我正在输入一个空格 + 按回车键,光标只是移动到下一行,没有任何反应。我怎样才能使它工作?

#include <cstdlib>
#include <iostream>
#include <cctype>

using namespace std;


int main(int argc, char** argv) {
cout << "Press a key please: " << endl;
char key;
cin >> key;

if (isalpha(key))
cout << key << " is a letter." << endl;
else if (isdigit(key))
cout << key << " is a number." << endl;
else if (isspace(key))
cout << key << " is a space." << endl;
else if (ispunct(key))
cout << key << " is a punctuation" << endl;
return 0;
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com