Being a C nerd, I occasionally browse the C library to discover new functions. Such an exercise is a must, not just for C but for any programming language. That’s because programmers can become complacent and rely upon the same old tricks. Only by reviewing the libraries, or by looking at other programmers’ code, can you learn new things.
Continue reading
Category Archives: Lesson
Reducing Roman Numerals
I’m sure a mathematical solution exists to condense Roman numeral values. The values ending in 4 or 9 can be reduced, but whatever that solution is, it’s beyond me. So for my resolution to the Roman numeral reduction problem, I rely on strings instead of math.
Continue reading
From Decimal to Roman
The C language lacks a printf() conversion character to display Roman numerals. Therefore, if your code requires input of a decimal value, say 266, and output of a Roman numeral value, which would be CCLXVI, you must craft your own function.
Continue reading
From Roman to Decimal
Roman numerals are composed of letters, so it makes sense that their “values” are input and displayed as strings. To translate from that string into an integer, your program must convert each character into its corresponding decimal value. Sounds simple, right?
Continue reading
Decimal, Binary, Hexadecimal, Octal . . . Roman
As a programmer, you encounter new counting bases: binary, hexadecimal, and perhaps octal. As a human, you use decimal, but decimal is only a recent invention. Before 1600 or so, if you worked with numbers you probably used Roman numerals.
Continue reading
The Ghost of Octal
Programmers become exposed to multiple counting bases as well as ways of representing values. As a human, you work in base 10, probably thanks to your 10 fingers. When you program, you learn about base 2 binary and base 16 hexadecimal. You study exponential notation as well, especially for crunching very large or very small values.
Somewhere in the mire, you encounter base 8, octal. You nod appropriately at the information as it’s glossed over, then you move on and never return to discover what was once a huge deal.
Continue reading
Yes! It’s a String – or Number!
The standard library functions atoi() and atof() work well to translate text (ASCII) input into values, an int or float, respectively. When your code must know whether a string is really a value, more processing is required.
Continue reading
Value or String?
My philosophy is to treat the input as a string until I can confirm that it’s not. The question then rises as to how strings can best translate into a value.
Continue reading
Manipulate Pointers in Functions, Part V
In Part II of this series, I showed code that let you pass a pointer’s address to a function. Within that function, the address can be manipulated and value at that address displayed. Can the same thing be done with a two-dimensional array, which is loosely related to a ** pointer?
Continue reading
Manipulate Pointers in Functions, Part IV
Those programmers I wrote about in last week’s Lesson, the ones who avoid the ** pointer notation, usually do so by using a two-dimensional array instead of the ** pointer thing. It’s a quick substitute, but it’s not exactly the same thing.
Continue reading