Last week’s Lesson brought the Poker program up to speed with regards to drawing a hand of 5 cards. The playing_card structure provides a convenient reference for each card, and the hand is sorted. Now comes the fun part: Determining the hand’s value.
Continue reading
Category Archives: Lesson
Drawing A Hand of Cards (Poker III)
Improving upon last week’s Lesson, this update to the playing card simulator offers one minor change: Multiple cards are pulled from the draw() function.
Continue reading
The Playing Card Structure (Poker II)
Drawing cards from a deck is an activity requiring more effort than flagging an element in an array, which was demonstrated in last week’s Lesson. Such code works, but it’s best to set details about the card when it’s drawn, noting its face value and suit, for example. Such complex information is best placed into a structure.
Continue reading
Draw Five Cards (Poker I)
To code a card game, you must start with the deck: 52 cards divided into 4 suits each consisting of 10 number cards and three face cards. Seems easy.
Continue reading
Structures and Arrays, Part III
I’ve wrapped up most of the oddities about structure/pointer/array notation in the past two Lessons (Part I and Part II). All that’s left is for me to go insane and start allocating structures as pointers with all their members as pointers.
Continue reading
Structures and Arrays, Part II
When it comes to structures and pointers, the structure-pointer notation is used only when the structure itself is allocated as a pointer (block of memory), not when a structure member is a pointer. Let me review from last week’s Lesson:
Continue reading
Structures and Arrays, Part I
Structures in C have their own issues when it comes to structure-pointers and structures within pointers. I wrote about this issue a few months back.
Another structure issue occurs with arrays within structures and arrays of structures. It also involves interesting notation — especially when you add pointers to the mix.
Continue reading
Extremely Buffered Output
A few weeks back, I wrote a post on the fflush() function, which immediately relieves an output buffer, releasing its contents. The mirror opposite of this function might be another output control function, setbuf().
Continue reading
The Teeniest of Tiniest
It took me a while to figure out the significance of the nextafter() function. Though I understand what it does now, I still can’t figure out how it’s useful, though I assume it has a valid purpose otherwise it wouldn’t be in the standard library.
Continue reading
Take it to the Limit
It’s been a while since I’ve been seriously concerned about wasting system resources. Back when I programmed a TRS-80 Model III with only 48K of RAM, keeping an eye on memory usage was vital. Today, not so much. In fact, if you desire to write code that consumes a lot of memory, CPU time, or other system resources, more power to you!
Continue reading