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
Author Archives: dgookin
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
Compiler Options in Code::Blocks
Like all IDEs, Code::Blocks is effectively a front for the clang, minGW, or gcc compiler lurking somewhere under its skin. While you don’t use these command line tools directly, you can control their options and settings from within the IDE.
Continue reading
Compiler Options at the Command Prompt
The traditional C compiler is cc. Its GNU replacement in the Linux world is gcc. A better option is the LLVM clang compiler. As commands typed at a prompt, you control these compilers by setting command line options or switches.
Continue reading
Find the Most Factors – Solution
The challenge for this month’s Exercise is to discover those values in the range 1 to 999 that have the highest number of factors. Never mind the math! Let C and the computer do the work for you.
Continue reading
Emulating the foreach Keyword
In last week’s Lesson, I covered how to obtain the number of elements in an array. This process is the first step to emulating the foreach keyword in the C language.
Continue reading