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 →

Safe Coding Practices – getchar() and putchar()

Posted on December 16, 2017 by dgookin
4

I confess that I get sloppy with getchar() and putchar(). These are macros, not functions, but the issue is that their return value is an int, not a char variable. The reason why is important if you want to follow safe coding practices.
Continue reading →

Posted in Lesson | 4 Replies

Safe Coding Practices – Terminating a String

Posted on December 9, 2017 by dgookin
4

String constants and strings created or manipulated by C library functions all set that terminating null character, '\0'. When you build your own strings, however, it’s easy to completely forget that null character. I know. I’ve done it.
Continue reading →

Posted in Lesson | 4 Replies

Swapping Arrays – Solution

Posted on December 8, 2017 by dgookin
2

The two functions required from this month’s Exercise are show_arrays() and swap_arrays(). They’re not that difficult to code, meaning that you don’t need to use the dratted ** notation or perform any special tricks. Here’s how I solved the problem:
Continue reading →

Posted in Solution | 2 Replies

Safe Coding Practices – String Handling 2

Posted on December 2, 2017 by dgookin
Reply

As with the strcpy() function, covered in last week’s Lesson, you run a risk of buffer overflow with strcat(). The compiler doesn’t check for an overflow; to ensure that you’re practicing safe coding habits, that task is up to you.
Continue reading →

Posted in Lesson | Leave a reply

Swapping Arrays

Posted on December 1, 2017 by dgookin
2

I’m amazed, and a bit envious, when I look at other programming languages to discover a rich variety of functions, or “methods,” that do specific tasks the C language lacks. One of these tasks deals with arrays.
Continue reading →

Posted in Exercise | 2 Replies

Safe Coding Practices – String Handling I

Posted on November 25, 2017 by dgookin
Reply

C offers a smattering of string-manipulation functions, but it leaves many of the critical issues up to you. Specifically, you must ensure that a string doesn’t overflow its buffer and that all strings are capped with the null character, '\0'.
Continue reading →

Posted in Lesson | Leave a reply

Safe Coding Practices – scanf()

Posted on November 18, 2017 by dgookin
Reply

When it was pointed out to me that using the scanf() functions in my online teaching material was an “unsafe coding practice,” I thought, “Well, duh!” I’ve never been a fan of scanf(); it’s an ugly function.
Continue reading →

Posted in Lesson | Leave a reply

Safe Coding Practices

Posted on November 11, 2017 by dgookin
Reply

Recently, I was notified of some weak programming practices common in beginning C material. As someone who appreciates solid code, I was surprised to hear about these items. As a teacher, I’m quick to address them.
Continue reading →

Posted in Lesson | Leave a reply

Filename Extractor – Solution

Posted on November 8, 2017 by dgookin
4

When I see a problem such as finding a filename in a pathname, one of the first things I think of are regular expressions. For this month’s Exercise, however, that’s not the solution I coded.
Continue reading →

Posted in Solution | 4 Replies

Sorted List Presentation, Part VI

Posted on November 4, 2017 by dgookin
Reply

With almost all the former-constants converted to variables, only one puzzle remains: Padding each string’s output so that the columns line up. (Yes, this is the final part of this series!)
Continue reading →

Posted in Lesson | Leave a reply

Post navigation

← Older posts
Newer posts →

Recent Posts

  • Storing and Interpreting Mouse Input
  • Where is the Mouse?
  • Pulling Numbers from a String – Solution
  • What is the Mouse Doing?
  • Pulling Numbers from a String

Recent Comments

  • dgookin on Reading Raw Input
  • Chris Webb on Reading Raw Input
  • dgookin on Is It a “Real” Triangle? – Solution
  • Chris Webb on Is It a “Real” Triangle? – Solution
  • dgookin on A Colorful Hexdump

Meta

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

Copyright © 1997-2026 by QPBC.
All rights reserved

Proudly powered by WordPress