Data in a matrix is entertaining and all that, but the point is usually to manipulate that data. The most basic form of manipulation I can conjure is to tally the rows and columns. Sounds like fun, but it took me a few attempts to get the code correct.
Continue reading
Category Archives: Lesson
Playing with a Grid
Grids, or matrixes, are a common data thingy, as information often appears in tables. Being able to fold, spindle, and mutilate a grid is a common computer programming task, something to entertain your idle hours even if you have no pressing need to manipulate a matrix.
Continue reading
Adding Values from Two Arrays
In last week’s Lesson, I covered a function present in other programming languages but absent in C: concatenating arrays. This time, the topic is similar: adding two arrays. Yes, such functions exist in other languages, but in C you must write one yourself.
Continue reading
Concatenating Arrays
Yet another tool missing from C, but found in other programming languages, is the capability to stick together two arrays. The result is a single, larger array containing the elements from the two originals. With C, of course, you can always code your own function to handle the task.
Continue reading
Counting Terminal Rows and Columns
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
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
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
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