Skip to primary content
Skip to secondary content

C For Dummies Blog

Main menu

  • C For Dummies (home)
  • History
  • Series
  • Supplemental
  • Blog Miscellany

Author Archives: dgookin

Post navigation

← Older posts
Newer posts →

Automated Guessing Game

Posted on February 1, 2020 by dgookin
Reply

Last month, I published a post of the classic programming chestnut, a number-guessing game. In the post, I wrote: “Variable tries is set equal to 6 because I read somewhere that it’s possible to guess a value between 1 and 100 in six or fewer tries (though I’m probably incorrect).” And, yes, I was wrong.
Continue reading →

Posted in Exercise | Leave a reply

Hunt the Wumpus

Posted on January 25, 2020 by dgookin
4

Original Wumpus artwork
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 →

Posted in Lesson | 4 Replies

The Essence of the Text Game

Posted on January 18, 2020 by dgookin
Reply

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 →

Posted in Lesson | Leave a reply

Fun with the asprintf() Function

Posted on January 11, 2020 by dgookin
Reply

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 →

Posted in Lesson | Leave a reply

Remove Trailing Blank Lines – Solution

Posted on January 8, 2020 by dgookin
Reply

The problem with snipping blank lines from the end of a file is storing the file as it’s processed. At least that’s the issue I faced as I worked through my solution to this month’s Exercise.
Continue reading →

Posted in Solution | Leave a reply

The snprintf() Function

Posted on January 4, 2020 by dgookin
Reply

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 →

Posted in Lesson | Leave a reply

Remove Trailing Blank Lines

Posted on January 1, 2020 by dgookin
Reply

Recently, I wrote a utility that required the final line of text in a file to terminate with a special code. The code had to sit at the end of a line of text, not on a blank line. What I discovered is that many text files end with one or more blank lines.
Continue reading →

Posted in Exercise | Leave a reply

My own strlcat() Function

Posted on December 28, 2019 by dgookin
Reply

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 →

Posted in Lesson | Leave a reply

Decoding the strlcat() Function

Posted on December 21, 2019 by dgookin
Reply

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 →

Posted in Lesson | Leave a reply

My Own strlcpy() Function

Posted on December 14, 2019 by dgookin
2

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 →

Posted in Lesson | 2 Replies

Post navigation

← Older posts
Newer posts →

Recent Posts

  • Colorful Data Chunks
  • A Little Bit Off the Sides – Solution
  • Working with Data Chunks
  • A Little Bit Off the Sides
  • From Decimal to Fraction

Recent Comments

  • dgookin on A Little Bit Off the Sides – Solution
  • Jack Bolt on A Little Bit Off the Sides – Solution
  • dgookin on Working with Data Chunks
  • Chris Webb on Working with Data Chunks
  • M.Stumpfl on From Decimal to Fraction

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Copyright © 1997-2026 by QPBC.
All rights reserved

Proudly powered by WordPress