Skip to primary content
Skip to secondary content

C For Dummies Blog

Main menu

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

Category Archives: Lesson

Post navigation

← Older posts
Newer posts →

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

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

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

Non-Standard Function: strlcpy()

Posted on December 7, 2019 by dgookin
Reply

I though writing a substitute strlcpy() function would be easy. Boy was I wrong!
Continue reading →

Posted in Lesson | Leave a reply

Non-Standard Function: strcasecmp()

Posted on November 30, 2019 by dgookin
3

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 →

Posted in Lesson | 3 Replies

Functions as Structure Members

Posted on November 23, 2019 by dgookin
5

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 →

Posted in Lesson | 5 Replies

Deviously Playing with Memory

Posted on November 16, 2019 by dgookin
2

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 →

Posted in Lesson | 2 Replies

Playing with Memory

Posted on November 9, 2019 by dgookin
Reply

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 →

Posted in Lesson | Leave a reply

Post navigation

← Older posts
Newer posts →

Recent Posts

  • Extracting Data Chunks
  • C Blog 13th Anniversary
  • Colorful Data Chunks
  • A Little Bit Off the Sides – Solution
  • Working with Data Chunks

Recent Comments

  • dgookin on C Blog 13th Anniversary
  • M.Stumpfl on C Blog 13th Anniversary
  • Chris Webb on C Blog 13th Anniversary
  • M.Stumpfl on A Little Bit Off the Sides – Solution
  • dgookin on A Little Bit Off the Sides – Solution

Meta

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

Copyright © 1997-2026 by QPBC.
All rights reserved

Proudly powered by WordPress