Difficulty: ★ ★ ★ ☆
The classic paradigm for swapping values between two variables involves using a third variable. But is the third variable even necessary?
Continue reading
The classic paradigm for swapping values between two variables involves using a third variable. But is the third variable even necessary?
Continue reading
The time.h
header defines a handful of functions useful for discovering and manipulating today’s date. Especially the localtime() function, which translates a time_t (Unix Epoch) value into date fields for output or manipulation. It’s a wonderful tool, but what does it tell you about yesterday?
Continue reading
The file utility in Linux quickly identifies known file types. It identifies text files, graphics images, or other common file types by using some sort of magic beyond checking the filename extension (which isn’t a guarantee). You can employ similar sorcery by writing your own Is It ASCII program.
Continue reading
You have a number of options for merging values between two arrays. I suppose the solution you devise depends on how you interpret the word “merge.”
Continue reading
A for loop statement contains three parts: initialization, termination, and while-looping. If you omit any part, the compiler assumes the value one, or TRUE, as the value, so the statement for(;;)
becomes an endless loop. The opposite of omitting is loading up: You can state multiple initialization and while-looping expressions in the statement, which can make a for loop truly compact.
Continue reading
The stat() function returns various tidbits about a file, including its timestamp, permissions, file type, and the file’s size in bytes. This value can also be obtained without without using the stat() function, which is this month’s Exercise.
Continue reading
I’ve covered the miraculous qsort() function elsewhere in this blog. It’s nifty, allowing you to sort all kinds of data with your only job being to code a compare() function. Most coders these days just copy-paste this function and call it good. But for sorting an array of structures, more brain muscle is required.
Continue reading
Text mode need not be so dreary when it comes to generating a game of chess. You have several options, all of which stink to varying degrees.
Continue reading
I think most kids delight at discovering the palindrome, where a word or phrase contains the same letters read forward or backwards. For example, racecar, which is really two words but never mind! Imagine how such fun can be spoiled by applying the same rule to a number.
Continue reading
Oh, leave it to the propeller heads to devise a clever and fun name for something the rest of us never pay attention to. This time it’s a cyclops number, which is any decimal integer value with an odd number of digits and a big fat zero in the middle — like a cyclops’ eye.
Continue reading
Copyright © 1997-2024 by QPBC.
All rights reserved