Hello there, guys!

I am quite some time now into programming, but have been dealing with C source codes for a short time. After creating some very basic programs, I want to do something more "sophisticated", might I use this expression. But let me not beat around the bush and get to the point.

I want to make a Tic-Tac-Toe game (that is, I'm almost done with it), but in order to play, one needs to enter the co-ordinates of the cell one wants to play in. That is, if one wanted to put his move into the upper left corner, one would need to type in 1 1 and press ENTER.
What I want to do is make the program "perceive" the keystrokes of the user, and deal with them accordingly. In the above instance, the only thing one would need to do, should I know how to do it, would be to press the 7 on the numpad.

My question is, do I have this option in C, or will I need to proceed to learning C++? And if I can make it in C, in which way exactly?

Any help will be appreciated. Thank you for reading this post!

What is your operating system? Are you trying to write a Console Application or a GUI Application?

it can be done easily, though the libraries needed are pretty much platform specific as they depend on operating system calls which themselves rely on hardware calls.

Basically you have a loop which polls the keyboard (or waits for input from the keyboard) and quits when input is received (or calls a function when input is received depending on that input).

I am running Windows XP Pro English SP2, and I am trying to make a Console Application using DevC++ (it's the latest edition, beta).

Now, about the loop, I came to think that much. The problem is, to receive a message from the keyboard, the ENTER must be pressed, with the things I know so far. That's why I am actually looking for the function that receives a message without the ENTER being pressed.

By the way, a "beta" edition of the Tic-Tac-Toe is ready... If anyone wants to see it, you can get the zipped file here... Just when you run it, maximize the window so it looks the way I intended...

Could you please post the code? I usually dont like running other people's exe files.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.