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 →

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

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

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

Sorted List Presentation, Part V

Posted on October 28, 2017 by dgookin
Reply

The process of converting the sample program from one that relies upon constants to one that exclusively uses variables is nearly complete. Only two steps are left:
Continue reading →

Posted in Lesson | Leave a reply

Sorted List Presentation, Part IV

Posted on October 21, 2017 by dgookin
Reply

Last week’s Lesson accomplished the task of obtaining the number of elements in the fruit[] array. This week, the task is to obtain the next item, the widest string in the array. This item is currently a constant, but it must become a variable to ensure the code’s flexibility.
Continue reading →

Posted in Lesson | Leave a reply

Sorted List Presentation, Part III

Posted on October 14, 2017 by dgookin
Reply

Once you accept that a program’s data set is flexible, you must abandon all constants and use variables. It’s a good move: The variables ensure that no matter what changes with the data, the code can handle it.
Continue reading →

Posted in Lesson | Leave a reply

Sorted List Presentation, Part II

Posted on October 7, 2017 by dgookin
Reply

It’s easy to code single-column list output. It takes a bit more programming skill to present the list in columns. To sort the list by columns is the most difficult. Like many programming tasks, it’s one of those things that once you figure it out, you just keep stealing your own code to do it again and again.
Continue reading →

Posted in Lesson | Leave a reply

Sorted List Presentation, Part I

Posted on September 30, 2017 by dgookin
Reply

Sometimes programming can be a snap, especially when you have a known data set and pretty much all the values are static. You can whip out code right away, it runs well and looks beautiful — but that’s because everything is known. The fewer variables, the easier to code.
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