I used to add humorous quips to my course, suggesting that you never leave your name in the comments or, if you did, erase it before moving on to a new job, lest someone call you in the middle of the night when the program fails.
I illustrated various C errors by describing them and mentioning how doing x,y, and z could really mess up your code. I also cautioned them that as stewards of their code, they should always fix a bug and leave a new one for future programmers.
I learned this approach to teaching from a telecommunications course I took, where the instructor would include stories that still resonate with me today.
---
One story was about a company named Expandor, which developed custom compression algorithms for clients. In one instance, they had statistically mapped the character alphabet used by a company's terminal application and recommended a new character encoding similar to the ETAON frequency alphabet, where E was represented by 01 and T by 011 ...
He continued that, true to their name, the data stream was many times longer than expected when they implemented the scheme at the customer's site.
The culprit was the RUBOUT character, which was scattered throughout their data stream and used for cursor movement. It acted as a screen-based form application where users tabbed to the next field to input data, and the rubouts served to separate one fixed-length field from another.
They hadn't considered the hidden ASCII codes in their analysis.
---
Another story he mentioned was how someone could overwhelm bank communications by injecting transactions with invalid checksum codes (ie whatever scheme the bank used to validate the transaction) into the stream in ever-increasing numbers until the bank personnel thought there was an error in the data stream checking algorithm and simply approved transactions. At that moment, you would send in your real transfer request and run off with the money.
I'm sure these kinds of problems can no longer occur, but both stories served as cautionary tales meant to emphasize the importance of careful design, implementation, and extensive testing.