From last week’s Lesson, the code I wrote for my clock program outputs the current hour and minute. I also want it to update, to keep running and output the next minute and so on. To me, that’s the difference between a clock program and code that just outputs the current time.
Continue reading
Author Archives: dgookin
Tick-Tock Goes the Clock, Part I
The other day I had this strong urge to write myself a text mode clock program, one that runs at the command prompt. This desire harkens back to my days programming text mode computers: I don’t need a clock, I just wanted to see if I could code one.
Continue reading
Variable Argument Lists
I’ve often wondered how it works. The printf() function has one argument minimum, a formatting string. Yet how does the compiler know how many other arguments are required? It’s not really a mystery, once you understand the concept of variable argument lists.
Continue reading
The Whole Month from a Single Day – Solution
The key to creating a calendar is to know on which day of the week the first of the month falls. This datum can be extrapolated from any other day of the month, as long as you know on which day of the week it falls.
Continue reading
The Whole Month from a Single Day
Months have a pattern: All months feature weeks of seven days. The month can start on any day of the week. And months have a varying number of total days, 28, 29, 30, or 31. Given this data, you can display the days and weeks of any month when given only a specific date and the day of the week upon which it falls.
Continue reading
The Ins and Outs of fgets()
With the demise of the gets() function, fgets() remains the top C language text-input function. Whether reading from a file or from standard input, the function is quite useful, but it’s not without some quirks.
Continue reading
Dealing with Structures, Pointers, and Files
For pointer structures, the process of writing the structure to a file works similarly to writing a non-pointer structure, but it’s not without some pratfalls. Further, if you have a structure that contains a pointer, things get hinkey quickly.
Continue reading
Reading and Writing Structures to a File
You need not read all structures from a file when you know the exact one you want. To fetch that record, you use the fseek() function. This function manipulates the file position indicator, allowing for random access to a file’s data.
Continue reading
Random File Access
Sequential file access works like a tape recorder — if you remember using one. Data is read from byte 0 through the last byte in the file, one after the other. Random file access can be sequential, but you can also hop around within the file, reading a chunk here, writing a chunk there. The secret has to do with the how the file position indicator is manipulated.
Continue reading
Counting in Alphabedecimal – Solution
Yes, it’s possible to code a program that counts in alphabedecimal from AAAA to ZZZZ without using nested loops. You must use a single loop, of course, but no cheating as shown in the original Exercise post.
Continue reading