One of the first functions C programmings learn is max(). It’s simple and useful, and it teaches a lot about functions and evaluations. Most programming languages also demonstrate functions similar to max().
Continue reading
Author Archives: dgookin
Looping with Testing Variables
Often in my code I use a variable to both fetch data and to test the data. Before using this variable, it must be initialized, lest the test act on uninitialized garbage. A clever solution is necessary to avoid this situation.
Continue reading
The Most Curious Aspect of the scanf() Function
It’s incorrect to say that the format string for the printf() function is identical to the one used in the scanf() function. Both are similar, but scanf() has one major difference.
Continue reading
Spelling Numbers – Solution
The task for this month’s Exercise is to write code that outputs strings for number values, 0 through 100. Your goal is to be clever with your solution, something that took me a few versions to get correct.
Continue reading
Fully Abusing the scanf() Function
It’s sad but understandable that most C programmers use the scanf() function in a limited capacity. True, the function is dorky, so I accept any aversion to its use. It can also be abused to pose a security risk. Still, for “research purposes,” it’s entertaining to see how much the function can be twisted and torqued.
Continue reading
Spelling Numbers
I would guess that most beginning programmers can deftly craft a loop that outputs sequential integer values, say from 0 to 100. In fact, this is the type of code I write whenever I learn a new language. I asked myself, “Can I write a loop to output values 0 to 100?” Usually in no time, I’ve constructed such a program. Simple.
Continue reading
Unraveling the scanf() Function
One of the things I dread in my books, is foisting the scanf() function upon a beginner. I have no way around this frustration.
Continue reading
Initializing an Array
Like all variables in C, arrays are declared uninitialized. They contain whatever junk already exists in memory. Initializing an array is therefore important. It can be done in one of three ways: as it’s declared, in a loop, or as it’s used in the code.
Continue reading
The 21 Number Game
I occasionally visit Rosetta Code to look for C language inspiration. The site offers a programming puzzle, then presents solutions in various languages. A recent challenge involved the 21 number game — but the C language had no solution!
Continue reading
The switch Condition
A switch-case structure performs a complex decision in your code, similar to a cascade of if else-if else statements. The structure works like a comparison as a whole, acting upon single values or variables. But its construction need not lack expressions.
Continue reading