In my books, I use the binbin() function to display binary values. It’s a good way to demonstrate some of the C language’s low-level bitwise functions: The binbin() function lets you see the effect of bitwise operations at a binary level, all those ones and zeros.
Continue reading
Highlight a Chunk of Text
Most of the common data formats, such as CSV, XML, and JSON, use plain text to store complex data or somehow interpret that plain text as something it’s not. The programmer’s job is to translate the plain text and generate the proper type of complex data.
Continue reading
The Standard Error Device
Oh, I could have fun with the term “standard error device.” It could be any PCs running Windows 8. [rimshot] See? Tech humor! It’s nerdy, but that’s not the point of the standard error device with regards to C programming.
Continue reading
Reading File Dates
The process of opening, reading, writing, and closing files is basic C language stuff. For specific details about a file, the stat() function is used to fill a stat structure. Unfolded are the nitty-gritties about the file itself, such as its size, ownership, and up to four time-date stamps.
Continue reading
When There is No π
Reader Chris pointed out a fun and common C language inconsistency in last week’s Lesson: The constant M_PI isn’t always available. It’s not defined as part of the C standard, which means your compiler may lack this handy shortcut, located in the math.h header file. What to do, what to do?
Continue reading
π Day
Mathematic geeks of the world celebrate March 14 as “pi day.” The logic is that the date is 3/14, which are the first three digits of the value π, or 3.14159….∞
Continue reading
Increasing Brightness – Solution
The challenge for this month’s Exercise is to fill a cup without overflowing it. That cup is an unsigned char value, which goes only to 255 maximum. If your goal is increase the value of an unsigned char variable by 10 percent, any value over 255 - (255/10), or 220, must be set to 255.
Continue reading
From the C Relic File: auto
Of all the C language keywords you don’t use, auto is probably the most memorable. That’s because it’s listed first among the canonical table of 32 C language keywords. Yet, in all the code you’ve written or seen, auto is seldom used if at all. So what does it do and is it even necessary?
Continue reading
Increasing Brightness
Recently, I did some graphics programming. The task I gave myself was to highlight a JPEG by drawing a box around an interesting part of the image. The puzzle was which color to make the box so that it would stand out.
Continue reading
Variable Width Values in Conversion Characters
The topic of conversion characters, or printf() percent placeholders, is vast and confusing. Most programmers know the basics, but the details are so complex that some handy shortcuts are overlooked. One of those shortcuts is the * wildcard that sets width values.
Continue reading