In the C language, a structure is used to express complex data types. The structure contains members that describe different parts of this complex data, such as a matrix required in this month’s Exercise.
Continue reading
Author Archives: dgookin
Modifying an Array
I’ve seen functions (okay, methods) in other programming languages that let you digitally tussle with an array. You can split an array, trim it, expand it, insert elements, remove elements, and so on. Such things are possible in C, but you must code the function yourself.
Continue reading
Describing Complex Data
Difficulty: ★ ★ ☆ ☆
I’ve written many C programming Lessons and Exercises that deal with matrixes. For most of them, such as rotating a matrix, I rely on uniform matrix sizes, like 5×5 or 10×10. This approach makes coding easier, but it doesn’t properly describe every type of matrix.
Continue reading
More Messing with Array Subscripts
I’ve written before about array subscripts and how they’re secretly expressions. But another weird aspect of array subscripts also looms on the horizon: The format a[1]
can be written as 1[a]
.
Continue reading
Exploring Allocated Memory
Details about a pointer can easily be obtained and output: it’s name, address, and contents. Obtaining the size of the buffer it references, however, is a different animal.
Continue reading
The Art of Memory Reallocation
Clearing the pointer hurdle is a major leap to learning the C programming language. Using the malloc() function to allocate storage is central to grasping this concept. Then along comes the realloc() function, and minds are blown.
Continue reading
Hungarian Notation Rhapsody
The rules for naming variables, or identifiers, in C are simple: The names must start with a letter and contain letters and numbers. The _ (underscore) counts as a letter. Upper- and lowercase letters are considered differently. And only the first 31 characters are significant, though some platforms may extend this length.
Continue reading
The Seventh Line – Solution
This month’s programming Exercise isn’t as much about file access as it’s about dealing with a situation when no data is available. The task: Read the seventh line from a file.
Continue reading
What is This? Why do I Want It? What Does it Do?
Sometimes I turn off my programmer brain and look at code to admire it in an innocent way. At first glance a C program source code file looks poetic, using the same patterns and flow. Code is also cryptic, which inspires many programmers to try to invent a new way to do something in a charming and confusing manner. One of my attempts was to rationalize this expression: ++a++
Continue reading
The Seventh Line
Difficulty: ★ ★ ☆ ☆
For me, the scariest part of learning how to program a computer was file access. The problem was the horrid documentation. It introduced both sequential and random file access together without much explanation. So it was with much trepidation that I wrote my first file I/O program. That’s when I realized that the manual was stupid.
Continue reading