
Spewing data all over the screen might look impressive, as shown in last week’s Lesson, but the point of knowing where the mouse is and what it’s doing is to capture its data and make it available to your program for interpretation.
Continue reading
Author Archives: dgookin
Where is the Mouse?

Monitoring the mouse in a terminal window happens thanks to various ANSI commands. Last week’s Lesson demonstrated how mouse clicks are detected. By issuing another ANSI command, the mouse’s location data is obtained, but doing so carelessly can create a horrid mess.
Continue reading
Pulling Numbers from a String – Solution
This month’s C programming exercise is to extract numbers from a string. Specifically, your task is to code the extract() function that returns the address of a digit found in a string. This function must also be capable of repeat calls to continue locating digits within the same string.
Continue reading
What is the Mouse Doing?

Continuing from last week’s Lesson, once activated and configured, the output that mouse activity generates in a terminal window looks something like this:
Continue reading
Pulling Numbers from a String
Difficulty: ★ ★ ★ ★
Rarely in your programming journey will you encounter a situation where the data you need just pops up fresh, exactly the way you want it. The best situation is where the data is somehow formatted, which makes finding the tidbit you want easier. But often the data is unformatted, which makes fetching that one useful morsel a bit tricky.
Continue reading
Reading the Mouse in a Terminal Window

After I bought a mouse for my first PC, I set out to write a mouse-based program — a game. (The Microsoft Mouse manual came with the full API.) It was fun and challenging, as all programming tasks should be. Surprisingly, reading the mouse is also possible in a Linux terminal window — providing that you know the secret.
Continue reading
Direct Terminal Input
While raw terminal input allows standard I/O functions to capture uncooked text, another approach for reading the terminal may also capture a few uncooked morsels. This process involves using low-level file I/O commands. These functions are read() and write(), which are part of the POSIX standard.
Continue reading
Reading Raw Input
Switching between cooked and raw modes requires access to the terminal’s configuration data. In Linux, these settings are manipulated at the command prompt by using the stty ccommand. In a C program, you use various functions available in the standard library and defined in the termios.h header file.
Continue reading
Cooked or Raw?
When the waitress asks how I like my eggs, I answer, “Cooked.”
O, how we all laugh . . .
The humor here is that it’s assumed you desire your eggs to be cooked and the waitress’s question relates to the fashion by which the eggs are to be cooked: fried, over-easy, sunny-side-up, scrambled, poached, and on and on. But the question of cooked or raw also applies to standard input for a computer terminal.
Continue reading
Is It a “Real” Triangle? – Solution
The challenge for this month’s Exercise is to generate three random values and determine if they work as sides of a valid triangle. To make this determination, you must consider three types of triangles and test the generated values for each.
Continue reading