Pergunta

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

Foi útil?

Solução

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

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top