Recently, I was notified of some weak programming practices common in beginning C material. As someone who appreciates solid code, I was surprised to hear about these items. As a teacher, I’m quick to address them.
Continue reading
Filename Extractor – Solution
When I see a problem such as finding a filename in a pathname, one of the first things I think of are regular expressions. For this month’s Exercise, however, that’s not the solution I coded.
Continue reading
Sorted List Presentation, Part VI
With almost all the former-constants converted to variables, only one puzzle remains: Padding each string’s output so that the columns line up. (Yes, this is the final part of this series!)
Continue reading
Filename Extractor
Last month’s Exercise demonstrated a filename-extractor, but it cheated: The filename was always the same: same text, same length. That’s not always the case in the real world.
Continue reading
Sorted List Presentation, Part V
The process of converting the sample program from one that relies upon constants to one that exclusively uses variables is nearly complete. Only two steps are left:
Continue reading
Sorted List Presentation, Part IV
Last week’s Lesson accomplished the task of obtaining the number of elements in the fruit[] array. This week, the task is to obtain the next item, the widest string in the array. This item is currently a constant, but it must become a variable to ensure the code’s flexibility.
Continue reading
Sorted List Presentation, Part III
Once you accept that a program’s data set is flexible, you must abandon all constants and use variables. It’s a good move: The variables ensure that no matter what changes with the data, the code can handle it.
Continue reading
Right String – Solution
For this month’s Exercise, I offer both a string function solution as well as a solution that uses pointers. As you can guess, I thought of the string method first, which is where most programmers would run to avoid the dratted topic of pointers.
Continue reading
Sorted List Presentation, Part II
It’s easy to code single-column list output. It takes a bit more programming skill to present the list in columns. To sort the list by columns is the most difficult. Like many programming tasks, it’s one of those things that once you figure it out, you just keep stealing your own code to do it again and again.
Continue reading
Right String
A recent web page programming puzzle reminded me of an old BASIC language function, RIGHT$. The “right-string” function returns the rightmost n characters from a string. Such a function would have helped me greatly in my web page programming task.
Continue reading