I enjoy programming a computer the old fashioned way, in the text mode terminal window. Yes, it’s now a sad little “app” floating on a graphical screen. This burden doesn’t remove the charm, but it does raise an interesting issue when you try to get text mode output just right: How many rows and columns are there in the terminal window?
Continue reading
Author Archives: dgookin
A Compact for Loop
A for loop statement contains three parts: initialization, termination, and while-looping. If you omit any part, the compiler assumes the value one, or TRUE, as the value, so the statement for(;;)
becomes an endless loop. The opposite of omitting is loading up: You can state multiple initialization and while-looping expressions in the statement, which can make a for loop truly compact.
Continue reading
Checking the CPU Clock
The clock() function has nothing to do with human time. Nope. It returns a value from the computer’s CPU, the processor time. You can use this value to determine the amount of time it takes your programs to run.
Continue reading
Not Every Compiler Likes Your Code
You would think that the various C compilers deal with C code in the same manner. After all, they adhere to the same C standards, right? This compatibility makes it possible to compile and cleanly build C programs regardless of which compiler you use, right? Well, maybe not.
Continue reading
The volatile Keyword
Perhaps the most hilarious keyword in the C language is volatile. It’s a data type qualifier, which I discussed in last week’s Lesson. But this qualifier doesn’t mean that the data is unstable or risky to use, unlike other things described as “volatile.”
Continue reading
How Big is That File? – Solution
The challenge for this month’s Exercise is to return a file’s size without using the stat() function. My goal is to get you to think about various file tools and how they can be useful beyond their intended purpose.
Continue reading
Type Qualifiers: const and restrict
When describing data, the C language offers data types and data qualifiers. The data type is well known to any C programmer, defining the kind of data stored: char, int, float, and so on. The qualifier describes additional aspects of the data, such as how it’s used or whether the compiler should optimize the data’s storage.
Continue reading
How Big is That File?
Difficulty: ★ ★ ☆ ☆
The stat() function returns various tidbits about a file, including its timestamp, permissions, file type, and the file’s size in bytes. This value can also be obtained without without using the stat() function, which is this month’s Exercise.
Continue reading
A Character-to-String Function
Modern programming languages have libraries rich with routines, functions, and methods — plenty to pull together and craft the code you want without getting into the nitty-gritties or reinventing the wheel. As a mid-level language, C often requires that you craft your own functions, a task I undertake with eager glee.
Continue reading
O Christmas Tree
It’s Christmas time, nerds rejoice! Welcome this festive season with a bit of programming acumen to festoon your old CRT monitor with some yuletide cheer.
Continue reading