문제

I am a beginner C coder and I want to know how the make it so the program will do this.

printf("which direction would you like to go?\n");
/*they type an arrow key*/
printf ("you went left/right/up/down\n");

I have a Mac

도움이 되었습니까?

해결책

Try these suggestions. You can get the ASCII codes by getch()

다른 팁

Pure C (and C++ by that matter) doesn't even require your system to have a keyboard, a mouse, or a screen (from the C++ FAQ, at http://www.parashift.com/c++-faq/input-output.html).

I would recommend searching for some sort of GUI (like Qt or GTK) in order to do stuff like that. I believe it is possible for ncurses to bind those sorts of events, if a command-line interface is what you want to do.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top