Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/164.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
getch()从一个箭头键中读取两个字符 今天我在测试C++中如何键按压,并为它做了简单的循环,发现GETCHE()由于某种原因复制了自己,或者IDK正在进行的事情,请看: #include <iostream> #include <windows.h> #include <conio.h> #define VK_H 0x48 using namespace std; int main() { int n=1; int total=0; bool theEnd=true; while(theEnd) { cout<<total<<endl; getch(); if(GetAsyncKeyState(VK_LEFT)) { total -=n; }else if(GetAsyncKeyState(VK_RIGHT)) { total +=n; }else if(GetAsyncKeyState(VK_LSHIFT) && GetAsyncKeyState(VK_F1)) { total = 0; } else if(GetAsyncKeyState(VK_ESCAPE)) { break; } } cout<<total<<endl; } #包括 #包括 #包括 #定义VK_H 0x48 使用名称空间std; int main() { int n=1; int-total=0; bool theEnd=true; while(theEnd) { 不能_C++ - Fatal编程技术网

getch()从一个箭头键中读取两个字符 今天我在测试C++中如何键按压,并为它做了简单的循环,发现GETCHE()由于某种原因复制了自己,或者IDK正在进行的事情,请看: #include <iostream> #include <windows.h> #include <conio.h> #define VK_H 0x48 using namespace std; int main() { int n=1; int total=0; bool theEnd=true; while(theEnd) { cout<<total<<endl; getch(); if(GetAsyncKeyState(VK_LEFT)) { total -=n; }else if(GetAsyncKeyState(VK_RIGHT)) { total +=n; }else if(GetAsyncKeyState(VK_LSHIFT) && GetAsyncKeyState(VK_F1)) { total = 0; } else if(GetAsyncKeyState(VK_ESCAPE)) { break; } } cout<<total<<endl; } #包括 #包括 #包括 #定义VK_H 0x48 使用名称空间std; int main() { int n=1; int-total=0; bool theEnd=true; while(theEnd) { 不能

getch()从一个箭头键中读取两个字符 今天我在测试C++中如何键按压,并为它做了简单的循环,发现GETCHE()由于某种原因复制了自己,或者IDK正在进行的事情,请看: #include <iostream> #include <windows.h> #include <conio.h> #define VK_H 0x48 using namespace std; int main() { int n=1; int total=0; bool theEnd=true; while(theEnd) { cout<<total<<endl; getch(); if(GetAsyncKeyState(VK_LEFT)) { total -=n; }else if(GetAsyncKeyState(VK_RIGHT)) { total +=n; }else if(GetAsyncKeyState(VK_LSHIFT) && GetAsyncKeyState(VK_F1)) { total = 0; } else if(GetAsyncKeyState(VK_ESCAPE)) { break; } } cout<<total<<endl; } #包括 #包括 #包括 #定义VK_H 0x48 使用名称空间std; int main() { int n=1; int-total=0; bool theEnd=true; while(theEnd) { 不能,c++,C++,备注 _getch和_getwch函数从 控制台,而不回显字符。这些功能都不能使用 用于读取CTRL+C。当读取功能键或箭头键时,每个 函数必须调用两次;第一次调用返回0或0xE0,并且 第二个调用返回实际的键代码 按箭头键时,输入为2个字符 备注 _getch和_getwch函数从 控制台,而不回显字符。这些功能都不能使用 用于读取CTRL+C。当读取功能键或箭头键时,每个 函数必须调用两次;第一次调用返回0或0xE0,并且 第二个调用返回实际的键代码 按箭头键时,输入为2个字符,不用担心,g

备注

_getch和_getwch函数从 控制台,而不回显字符。这些功能都不能使用 用于读取CTRL+C。当读取功能键或箭头键时,每个 函数必须调用两次;第一次调用返回0或0xE0,并且 第二个调用返回实际的键代码

按箭头键时,输入为2个字符

备注

_getch和_getwch函数从 控制台,而不回显字符。这些功能都不能使用 用于读取CTRL+C。当读取功能键或箭头键时,每个 函数必须调用两次;第一次调用返回0或0xE0,并且 第二个调用返回实际的键代码


按箭头键时,输入为2个字符,不用担心,
getch()
不应该在任何严肃的程序中使用,它甚至不是一个标准函数。所以不要太担心它。它是否仍然证明了你的问题?@Iharob Al-Asimi严肃的程序员使用的是什么?)@Ryan Haining不,它不是,问题在于箭头键。@Engelard可能不是来自玩具库的东西。不要别担心,
getch()
不应该在任何严肃的程序中使用,它甚至不是一个标准函数。所以不要太担心它。它是否仍然证明了你的问题?@Iharob Al-Asimi严肃的程序员使用了什么?)@Ryan Haining不,它不是,问题在于箭头键。@Engelard可能不是来自玩具库的东西。1.tried_getch-完全一样的东西,相同的结果。_getwch根本不工作(但包括库)。2.我将箭头键改为“H”按钮,它停止工作(当前的“if”语句),至少它不工作,如果我从代码中删除getch-“H”工作正常…@Engelard你添加到
getch()了吗
阅读那个额外的字符?天哪!我用了简单的getch(不是getch),现在它正常工作了。问题解决了,所有的Killzone小子!1.尝试了getch-完全一样的东西,相同的结果。\ getwch根本不工作(但包括库)。2.我将箭头键改为“H”按钮,它停止工作(当前的“if”语句),至少它不能与getch一起工作,如果我从代码中删除getch-“H”很好…@Engelard你添加到
getch()
来读取额外的字符了吗?天哪!我使用了简单的getch(而不是_getch),现在它可以正常工作了。问题解决了,所有的Killzone小子!