I’m constantly on the prowl for obscure and seldom-used C language functions and techniques. One I just discovered — despite coding in C for decades — is the token paste operator. It’s a weirdo.
Continue reading
Category Archives: Lesson
Hunt the Wumpus Code

I had a great time coding Hunt the Wumpus. Like most programming challenges, it was fun, exciting, and frustrating all at once. Some code ran beautifully the first time. Other code contained silly mistakes that bogged me down. And solutions unveiled themselves magically like a sugar cube dissolving in water.
Continue reading
Implementing Hunt the Wumpus in C

In last week’s Lesson, I described the history and gameplay for the classic text mode game, Hunt the Wumpus. The task of coding the game took considerably longer than writing the blog post.
Continue reading
Hunt the Wumpus

The game Hunt the Wumpus isn’t difficult to code in C. In fact, all you need do is start with the basic number-guessing game presented in last week’s Lesson and you can build just about any text-mode game. That’s what I did when I started my own C language version of Hunt the Wumpus.
Continue reading
The Essence of the Text Game
I was perusing Rosetta Code the other day, looking for more programming ideas to explore. One of the tasks provided, with examples in a variety of programming languages, was to code the old computer game Hunt the Wumpus.
Continue reading
Fun with the asprintf() Function
If you desire to store formatted output in a buffer, the snprintf() function, covered in last week’s Lesson, is a safe alternative to the standard Library sprintf() function. An even better choice is the asprintf() function.
Continue reading
The snprintf() Function
Another non-standard library function is snprintf(). Like the strlcpy() and strlcat() functions shown in previous Lessons, snprintf() is safer than its standard Library counterpart, sprintf().
Continue reading
My own strlcat() Function
Coding my own version of the non-standard strlcat() function proved to be a bit more work than I anticipated. That’s because I also had to code my own versions of the strcpy() and strlen() functions to make the thing work.
Continue reading
Decoding the strlcat() Function
The strlcat() function (with the L) achieves the same goal as the venerable strcat() function: to append one string onto the end of the other. The problem with strcat(), however, is that a size limitation isn’t set for the destination buffer. It’s quite possible for this buffer to overflow.
Continue reading
My Own strlcpy() Function
Armed with information about how the non-standard strlcpy() function is implemented by my compiler (see last week’s Lesson), and fully testing its input and output, I was better able to craft my own version. Granted, it’s not the way I would have coded things on my own, but the point is to recreate the function exactly so it can be used as a substitute.
Continue reading