关于代码的几个问题 [英] Several Questions About Code
问题描述
string keystroke(char KeyStroke, string output2){
while (true==true) {
KeyStroke = getch();
if (KeyStroke == 0)
{
KeyStroke = getch(); // Even though there are 2 getch() it reads one keystroke
switch (KeyStroke)
{
case UP_ARROW:
Keystroke1 = "up";
charpos_calculation(Keystroke1);
break;
}
}
}
return output2;
}
_____________________________________________________________________________________________
问题1 - 跑步时我的程序返回此错误。此项目的POSIX名称已弃用
我需要做些什么来解决此问题。
问题2 - 我如何获得击键?我通过#define UP_ARROW 25来定义向上箭头。这是正确的方式和正确的价值。
我想弄清楚的是如何直接来自用户的键盘输入。我该如何操作,这样用户就不必按回车。
这是一个使用Windows Visual Studio 2012 Express的控制台应用程序。
这也是我的大型游戏代码的一部分。
_____________________________________________________________________________________________
Question 1 - When ran my program returns this error .The POSIX name for this item is deprecated
What do I need to do to fix this.
Question 2 - How do I get a keystroke? I defined the up arrow by #define UP_ARROW 25. Is this the right way and the right value.
What I'm trying to figure out is how to get direct keyboard input from the user. How would I do this so the user doesn't have to press enter.
This is a console application using Windows Visual Studio 2012 Express.
Also this is part of my code of a larger game.
推荐答案
问题1 - 运行时我的程序返回此错误。不推荐使用此项目的POSIX名称
我需要做些什么来解决这个问题。
Question 1 - When ran my program returns this error .The POSIX name for this item is deprecated
What do I need to do to fix this.
我认为这是一个警告,而不是错误。无论如何编译器是对的,当然:-),请参阅文档 [ ^ ]用于修复(即使用 _getch [< a href =http://msdn.microsoft.com/en-us/library/078sfkak(v=vs.110).aspx\"target =_ blanktitle =New Window> ^ ] )。
I believe that is a warning, not an error. Anyway the compiler is right, of course :-), see the documentation[^] for a fix (that is use _getch[^] instead).
问题2 - 如何获得击键?我通过#define UP_ARROW 25来定义向上箭头。这是正确的方法和正确的值。
Question 2 - How do I get a keystroke? I defined the up arrow by #define UP_ARROW 25. Is this the right way and the right value.
你可以测试它。
这篇关于关于代码的几个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!