A basic C language process is passing a value to a function. If you’re an old hand, you might say, “Yeah, well, so?” For a beginning programmer, however, functions and their arguments can be a confusing and intimidating ordeal.
Continue reading
Author Archives: dgookin
scanf() the Bastard
When you first learn the C language, and you’re practicing basic input/output, you become familiar with the two I/O workhorses of the C library: printf() and scanf(). Of the two, printf() is my favorite. The scanf() function is highly useful, and it’s a great learning tool, but it’s not the best function for reading in a string of text.
Continue reading
One Year Anniversary
This post marks one year of the Unofficial C For Dummies website blog. Yeah!
I started this blog before the book was published. I wanted to ensure that anyone who bought the book would actually have some content up and available should they click the link. And I wrote a few posts before hot-linking the blog, just to make it more lively.
It’s been fun working this blog for the past year. I look forward to many more posts in the future. If you have any questions on my programming books, please email me; my address is shown below.
And remember: You don’t need an account here to enjoy the posts. If you’d like an account, send email to dan@c-for-dummies.com and I’ll set you up. No problem!
Reading Command Line Options
You might think that the command line is a relic of the past. For a mortal user, that’s correct: The only people I know who still dwell at the command prompt are power users. I keep a command prompt (terminal) window open on my computers, just because using the terminal is fast and I happen to know the commands. Yet, internally, all graphical operating systems still reference the command line.
Continue reading
Manually Allocating a Pointer Array
A few Lessons ago, I mentioned that a variable such as **months couldn’t be used to declare an array. That’s true because the **months construction doesn’t use array notation. Duh. That doesn’t mean that **months is totally out of luck.
Continue reading
A Simple Calculator
Of course computers can do math! Of course, programming has some math in it! Yet one reason that programmers are not necessarily geniuses at math is that it’s the computer that does the math, not the programmer. To prove that truth, why not code your very own calculator program?
Continue reading
Direct String Manipulation
As programmer, you have a choice: You can manipulate information as it’s sent to output or you can manipulate it in memory and then send the result to output. Depending on what the program does, however, you may not have that luxury. Sometimes you must make modifications in memory, saving them for later.
Continue reading
The Art of String Manipulation: Spaces to Newlines
The C language lacks a sack of tools for manipulating strings. For most string-mangling operations, you’re pretty much left to carve out your own tools. Doing so may involve pointers, but it doesn’t necessarily have to.
Continue reading
Getting Shifty
Something that you can do in the C language that C++ programmers cannot is employ the shift operators. These operators, << and >>, serve as I/O operators in C++. In C, however, they can be used to manipulate values at the bit level in C, which is part of the C language’s mid-level heritage.
Continue reading
Splitting Things in Half
It’s pretty safe to avoid your first instinct when it comes to dividing two integers. That first instinct is most likely to typecast the int values as float. That works, and many times it can be the best solution, but it’s not always the solution.
Continue reading