Tip-a-day mode29 September 11. [link] PDF version
For the next several weeks, I'll be giving a tip about writing in C every other day. People seem to like the tip-a-day sort of format, so I thought I'd try it out for a while.
When I type c tutorial into a search engine, most of the top hits are from somewhere in the mid-1990s. They're not obsolete in the sense that everything they say is still correct, but in the last fifteen years or so, coding style and custom--and the C language itself--have changed.
This makes me sad, because C is a spiffy, awesome, moderner-than-modern language, and we shouldn't let tutorials copyright 1987 drag it back to the mainframe era. These tips assume that you've already read these tutorials and/or somehow picked up the basics of C. You can write C using about a dozen and a half keywords, so it's not rocket science. These tips will show you how to get around the awkward bits and use C like a modern, script-like language, with less overhead and fewer calls to malloc.
There are a lot tweet-length tip-a-day setups out there (A Mr. Cook has about a dozen), but these are here on the blog so I'll have room to give detail, backstory, and running sample programs. Don't worry--none of them will take more than a minutes or two to absorb.
If you want some starter content, maybe start with a (longer than tip-length) post from last week, about curly braces and scope.