I though writing a substitute strlcpy() function would be easy. Boy was I wrong!
Continue reading
Category Archives: Lesson
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 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
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
Four-of-a-Kind, Three-of-a-kind, and a Full House (Poker VII)
To effectively evaluate poker hands, the next sequence after a straight, straight flush, and flush draw (covered in last week’s Lesson) is to evaluate four-of-a-kind, then three-of-a-kind, and (while you’re at it) a full house.
Continue reading
Flush, Straight, and Straight Flush Tests (Poker VI)
After pulling out any hands arranged in a straight pattern, covered in last week’s Lesson, the next logical test is for a flush. The flush draw is when all cards are of the same suit.
Continue reading
Straight Draw (Poker V)
The first test for a hand of five cards is the straight, specifically an Ace-high straight followed by a standard straight. To perform this test, I’ve concocted a special version of the program, one that has a set of pre-drawn poker hands.
Continue reading