From the history of the Unix operating system, glob is the term used for wildcard matching in filenames. It’s short for global, which to me means that two extra bytes of storage (for 'a' and 'l') were important back in the day.
Continue reading
Author Archives: dgookin
Watch the Stock Market
Difficulty: Medium
Stock prices fluctuate throughout the day based on news, fear, and speculation. If you own stock and desire the price to rise, you anxiously watch the stock tickers throughout the day, puzzled or delighted by the reactions. This month’s Exercise attempts to emulate such anxiety.
Continue reading
Wild About Wildcards
Wildcards were highly useful during the glory days of text mode operating systems. They still exist: ? represents a single character in a filename and * represents a group of characters. Using wildcards to manipulate files is a staple of computer file management, perhaps a lost art in the era of graphical operating systems, but still relevant. The C language is also still relevant, so how does it deal with wildcards in a filename?
Continue reading
Creating a Pointer Array (Correct)
Unlike the iffy issue with assigning a pointer directly to a string, you cannot declare a pointer and assign it an immediate value. This puzzle was presented in last week’s Lesson. No, to do things properly requires not a single statement but three separate steps.
Continue reading
Creating a Pointer Array (Wrong)
I’m delighted to receive reader email regarding the various puzzles in the C programming language. Some of them involve creative thinking and approaches that seem like they work — but don’t. Pointers are one of the most common subjects.
Continue reading
Unravel the Mystery Code – Solution
I hope you enjoyed crafting your solution for this month’s Exercise. It’s just for fun, as I assume no one is going to mess with C to such a degree that their code becomes so completely unrecognizable. Still, C coders are a mischievous bunch.
Continue reading
The _Generic Keyword
The C11 standard added the “underscore” bunch to the C language’s traditional keywords:
_Alignas
_Alingof
_Atomic
_Bool
_Complex
_Generic
_Imaginary
_Noreturn
_Static_assert
_Thread_local
I don’t routinely use any of these in my programs, beyond trying a few out to see how they work. The _Bool keyword comes in handy. The rest? Well, they’re worth exploring from a curiosity standpoint. For this week’s Lesson, I reveal the mysteries of the _Generic keyword.
Continue reading
Unravel the Mystery Code
Difficulty: Easy
The C compiler preprocessor is a sneaky and powerful thing. I’m unsure of any other programming languages that have such a tool.
Continue reading
Putting the memset() Function to Work
My approach for initializing a buffer is to use a loop and assign each byte a value such as zero or the null character, '\0'. It’s tedious, but necessary. And for the impatient, some functions are available to perform this task for you.
Continue reading
How Big is Your BUFSIZ?
When my code requires a random odd buffer, I generally assign it a given size in some holy computer value: 16, 32, 64, and so on. But a defined constant exists, BUFSIZ, that can also be used to set a buffer size safely and consistently on all C compilers.
Continue reading