The two problems I recognized in the code from last week’s Lesson were that scan_column() and find_right() don’t need to be separate functions. Also, the code fails to find all the rectangles in the grid, which is bad. Time to fix the code!
Continue reading
Category Archives: Lesson
A Grid of Random Stars, Part IV
I was so excited with last week’s code that I didn’t bother to confirm that it worked properly. No, I was eager to see graphic output of the found rectangles.
Continue reading
A Grid of Random Stars, Part III
The next update to my pattern-finding program is to hunt down and find a clutch of asterisks in the grid that form a rectangle. Figure 1 illustrates what I’m after.
Continue reading
A Grid of Random Stars, Part II
To count all possible rectangles in a random grid requires a lot of scanning. My first thought was that the process would involve recursion. I wasn’t 100 percent certain, but I wanted to prep the code for such a possibility.
Continue reading
Analyzing a Grid of Random Stars
Ever since I was a little boy and coded my first nested loop, I’ve enjoyed messing with grids in C. I’ve done monthly calendars in grids, rotated grids, manipulated grids mathematically — all sorts of fun girddy stuff. But I’m not done yet.
Continue reading
Messing with Array Subscripts
Array notation involves the array’s name followed by a set of square brackets. Within these brackets is a reference to the array element’s number. It’s important to remember that the first element is zero. But the subscript need not always be a constant integer.
Continue reading
Tending Toward Obfuscation
I’m always mindful of the beginner when I write code for this blog. Even with my own code, I often go to pains to write things “the long way” just because I’m in the habit. Not every coder is so thoughtful. The reason is that C tends toward obfuscation. We must revel in this capability.
Continue reading
From Void to Integer
You can’t just slap a data type upon a variable declared as void. No, a void type can be assigned a pointer. But even then, you can’t just typecast that pointer as an int and get away with it.
Continue reading
Out of the void
The four standard data types in C programming are char, int, float, and double. A fifth type is void, which is used to declare storage of an unknown type. My goal is to see how badly I can abuse this data type.
Continue reading
Using the epoll() Function to Scan for Standard Input
As with the select() function covered in last week’s Lesson, you can use other networking functions to scan for pending standard input while a program otherwise spins busy. The epoll() family of functions allow for such monitoring.
Continue reading