I though writing a substitute strlcpy() function would be easy. Boy was I wrong!
Continue reading
Author Archives: dgookin
Morse Code Filter
I’m certain that the nerds would love debating whether the telegraph’s Morse code system was the first binary communications network. Let them do so. Still, Morse code remains a simple communications system, translating letters and numbers into dots and dashes — which you could argue are similar to ones and zeros.
Continue reading
Non-Standard Function: strcasecmp()
As part of my research, I run my C code on different platforms using different compilers. Occasionally I’m crushed to discover that my code won’t compile because my development computer uses a customized version of the C library, one that features a non-standard function, such as strcasecmp().
Continue reading
Functions as Structure Members
A programming puzzle kept me awake one night: If a structure allows for any variable type to be a member, and a function is a valid variable type, why not have a structure with a function as one of its members? Am I nuts?
Continue reading
Deviously Playing with Memory
When a buffer is void, its contents are treated as raw memory, not assigned to any specific data type. This ambiguity means your code can cast the memory’s data type and do interesting things with it.
Continue reading
Playing with Memory
Gone are the old days when your C program ruled the entire computer’s domain. Back then, you could access any chunk of memory in the computer, manipulate it in all sorts of interesting ways, and not be concerned that your code’s actions would be restricted. Ah, those were good times.
Continue reading
The Yorn Function – Solution
The most difficult thing about this month’s Exercise is to deal with stream input: When the user overstuffs the input buffer, those extra characters continue to flow into the program, interpreted as additional input and they make the output look ugly.
Continue reading
The Poker Program
With all the hand-ranking functions complete (see last week’s Lesson), the final version of my poker program restores the randomizer, draws and sorts a hand, then outputs the hand’s value. It’s quite disappointing.
Continue reading
The Yorn Function
When a computer program wants to know a Yes or No answer, the function I write is called yorn().
Continue reading
One or Two Pairs (Poker VIII)
Matching two card values in a poker hand counts as a pair. It’s the lowest-ranking hand (above the non-ranked “high card”) and the most common. In my poker program, it’s also the last ranking hand tested.
Continue reading