Duplicated Letters

I’ve been working on a program that counts unique words in a text file. It’s an interesting exercise and explores the larger realm of pattern matching. You can try such scanning on a smaller scale by coding a program that counts the frequency of letters within a string. And that task is presented as this month’s Exercise.
Continue reading

Made-Up File Names

Many moons ago, I coded a file-renaming utility. It allows me to shuffle chapter names for documents used in my books, renaming a whole batch at once without overwriting existing filenames. It couldn’t happen if I didn’t know about the mktemp() function.
Continue reading

Fill My Grid

I’m fascinated by grids. Consider the chessboard, which is a grid. Or think about the most basic game grid, a 3-by-3 array for a game of tic-tac-toe. Programming a grid is a common thing, so your best hope is that this month’s Exercise is yet another super cinchy silly grid program.
Continue reading

Factors

Factor is a scary word, but not really a mathematical monstrosity. If you have an integer value, its factors are the other integers that can divide evenly into the original value. The computer can deftly discover these values, providing you give it the proper C code to munch upon.
Continue reading

Looping with time_t values

In C, the time_t variable type is associated with the Unix epoch, or the number of seconds ticked since midnight, January 1, 1970. It’s typically a long int value, though as a typedef declaration, its specific data type could change in the future. Still, as a long int, you can play with it like other integers in your code.
Continue reading