ユーザが押された矢印キーを出力します。私が手 出力は次のようになります。printf文字列出力 "Dz↕" getch()C++
"You pressed the Dz↕ button."
私が書いたものだった:
unsigned int key;
string K;
do
{
key = getch();
if (key==72)
K=" up";
else if(key==80)
K="down";
else if (key==77)
K="right";
else if (key==75)
K="left";
else
{}
if (key!=224)
printf("You pressed the %s button.\n", K);
else
{}
}while(key !='q');
return;
コンパイラがここに文句を言う必要があります... 'getchは()'を返すどのようなものです –
にしようとしていないchar *型を必要ですか?ほとんどの場合、初期化されていない文字列にはゴミが入っています。 – geoffspear