Often times I poke into the C language, removing its crude veneer to look deeper into its guts — the digital protomatter that C and all programming languages devolve into when processed by the CPU. One of the things I discovered is that there is no solid limit to the number of arguments a function can have.
Continue reading
Category Archives: Lesson
Crossing Between Formatted and Unformatted File Functions
One of the reasons behind the low-level open() function is to access non-traditional files. This stems from the UNIX environment’s treatment of every device as a file. Sometimes you need low-level access to accomplish specific tasks, such as accessing a device driver. Yet, in the C language universe, an interesting crossover is provided between low-level raw file access and formatted file access.
Continue reading
Writing File Data in the Raw
Along with open() as a raw file access function comes raw functions to read and write data. Last week’s Lesson covered the read() function. This week covers its twin sibling, write().
Continue reading
Raw Reading File Data
When you use the fopen() function to open a file for reading, a buncha functions are available for reading data: fread(), fgets(), fgetc(), and others I’m too lazy to look up. Reading files by using the open() function, however, gives you this choice: the read() function.
Continue reading
Opening a File in the Raw
The fopen() function opens a file or stream for formatted input. The “formatted” is where the function gets its f prefix, which I always thought stood for file. It doesn’t. The fopen() function is the formatted file (and stream) function, the open() function is for low-level, unformatted file access.
Continue reading
π Day Bonus!
I plan my Lessons weeks in advance. So, only recently did it dawn upon me that today is March 14th, 3/14, known to nerds all over as Pi Day. Here is yet another nerdy program I wrote to calculate the value of π:
Continue reading
Three-Way Evaluations
Being traditional and, to be honest, ancient, the C language deals primarily with two-way evaluations: a > b, c != d, r <= 0, and so on. Complex comparisons build upon these atomic nuggets, but among the trendy languages a newer alternative exists: the three-way evaluation.
Continue reading
Outputting Inverse Text
Early computer terminals were text-only output devices. Sure, some got fancy and could do color text, perhaps even underline. Many of the early terminals, as well as the first handful of microcomputers (ancestors of the modern desktop), generated only text with perhaps some inverse text to spice things up.
Continue reading
Suppressing a Terminal’s Character Echo
Back in the bad old days, you used a terminal connected to a mainframe to do your computer work. The terminal had a monitor and keyboard and just enough smarts to configure itself for communications with the mainframe. One of those configuration options was character echo.
Continue reading
Input Minus the Echo
The prompt appears in the terminal window: Type your password. As you type the password, text doesn’t appear on the screen. Yes, the program is using stream I/O. So how do you code standard input that doesn’t output characters?
Continue reading