Perhaps the most difficult part of learning C is understanding and coding pointers. Even when you have a grip on things, it helps to keep fresh and practice new and utterly obnoxious ways to play with pointers.
Continue reading
Category Archives: Lesson
Coding a Better stringcopy() Function
From last week’s Lesson, the task is to code a safer, better version of the strcpy() function. The goals are to check buffer size, report an overflow or underflow (buffer is too big or too small), and potentially confirm whether data is overwritten. Such a program is often used as a test when applying for a C programming job.
Continue reading
Copying Strings
The C language has string manipulation functions, but they’re tepid. In fact, the C23 update includes even more functions to duplicate strings and to stick them together. These actions are simple in other languages, but create such a problem for C that coding a string copying function is often a skill you must demonstrate when applying for a C programming job.
Continue reading
Finding Those Pesky Null Characters!
You’ve crafted a brilliant function, ensuring that it properly processes words and generates needed output. Is the code perfect? Well, it looks perfect. But how do you know for certain?
Continue reading
More Array, More Decay
I’ll be blunt: If you want to pass an array to a function, or have a function return an array, just give up now and use pointers. It’s a far easier operation, and it would save me the bother of having to write this post to further discuss the topic of array decay.
Continue reading
The Trouble with Array Decay
Array decay has nothing to do with too much sugar in your code or poor brushing habits. No, it’s a hot topic in C programming, and a source of confusion.
Continue reading
The Story of the Undefined Reference Error
Let me be blunt: If you haven’t yet seen an undefined reference error, you truly aren’t a C programmer. In fact, the more of these messages you see, the longer you’ve been coding in C. Undefined reference errors are a badge of honor.
Continue reading
Things That Bounce (Even More exp() Function Stuff)
It’s time to free yourself from the math-nerd aspect of the exp() function and put it to legitimate use by animating an asterisk bouncing across the screen. Such a feat may be considered unusual for a stream-oriented programming language like C, but I find animation more interesting than math.
Continue reading
Things That Fall (More exp() Function Stuff)
Text mode graphics were a Big Deal with computers for the longest time. C’s stream I/O didn’t stop various computer games from being developed throughout the 1970s and 1980s. And this limitation isn’t going to stop me from animating a falling ball, er, asterisk.
Continue reading
Fun with the exp() Function
Deep in the crevasse of oddball math functions is one that raises Euler’s number (e) to a given power. This calculation is vital enough in programming that it sports its own function, exp(). And I would ignore this function with exuberant glee were it not for a trick someone showed me a long time ago.
Continue reading