The 16-hour puzzle presented in last week’s Lesson has been resolved: It was actually a 24-hour puzzle, minus 8 hours for my time zone, which equals 16 hours. But what can be done about the time zone difference?
Continue reading
Author Archives: dgookin
Positive, Negative, or Zero
The strcmp() function returns a value based on the comparison of two strings. The value is zero when the strings match, otherwise the value is positive or negative depending on how the strings compare. This result makes me wonder which other functions can return positive, negative, or zero values and whether the C library has a sign() function or similar that helps make such a determination.
Continue reading
The time_t Value . . . and 16 Hours?
In last week’s Lesson, I covered the mechanics behind manually calculating a time_t value. My code was successful, but in a curious way.
Continue reading
Creating a time_t Value
Ho boy! This time_t project turned out to be a lot more complex than I thought it would be!
The problem: Count the number of seconds elapsed from January 1, 1970 to a given year, month, and day. This task is easy for a computer, but not that easy to code if you want to get the value correct.
Continue reading
Parsing Integer Values Into a time_t Value
Pulling a date from a string involves slicing the string into substrings, which are then converted into values for year, month, and day. Last week’s Lesson demonstrated such code. This week, the final step is accomplished, converting year, month, and day integers into a time_t value.
Continue reading
A Pair of Arrays – Solution
The challenge for this month’s Exercise is to initialize two different arrays to two sets of values. You should try to use only one loop and try to use a single statement to make the element assignments.
Continue reading
Parsing and Converting
The goal stated in last week’s Lesson is to convert a date formatted in a filename string into a time_t value. The filename string must be scanned for expected year, month, and date values. This process involves a custom function, convert(), as well as the strtol() function to translate strings of digits into long int values.
Continue reading
A Pair of Arrays
Removing redundancies from your C code may not be your first goal, but it’s something you can definitely find later. One example is when you must initialize a pair of arrays. Why use two loops when one will do?
Continue reading
It’s Parsing Time
A recent puzzle presented itself, one where I must extract a date based on a file’s name. The date is part of the name, but my code required I translate the date into a time_t value. It’s an awesome programming puzzle that involves many different tricks.
Continue reading
The 27th International Obfuscated C Code Contest

The results of the 27th International Obfuscated C Code Contest were announced earlier this month. The code is amazing. It runs. It’s horrifyingly cryptic.
Continue reading