Your browser doesn't seem to support CSS, which this page uses for all styling. Don't be surprised if it looks kinda boring.

[Jump to nav]



fread is a C program I wrote in less than 5 hours on a dare (with myself). It allows you to open an arbitrary number of files, move to specific spots in them, and read specific amounts of data from them.

This lets you manually test exactly what the results of read()'s in your programs will be, as well as details of the layouts of files.

It's a fairly simple program, but I've filed off most of the rough edges. It does a reasonably good job of protecting itself from you the user, but that doesn't mean you can't probably break it if you try hard enough. It just means you'd have to work at it.

And anyway, it was fun to write. Sure, some people might say it's a little silly to write 888 lines of code (per wc(1), as of version 1.1) just to wrap around a "read() - printf()" sequence. And they're probably right. But they're also boring :)

How to use it

Download and untar. There's a Makefile that should work with most make(1) programs out there, so just run 'make'. It requires perl in the build process, and the readline library, both of which are usually installed by default on most OSen these days, and are used by enough other programs that they're probably there on most systems. Once make finishes, you'll have a "fread" binary you can have your way with.

There's a README file in the tarball that gives a fairly good introduction to the program and a summary of its usage. It runs as an interactive program and accepts commands. The direct interface is managed by the readline library, so you get all the goodies like command-line history, editable history, and tab-completion of filenames. And since a lot of what you're doing with the program is opening files, that comes in pretty handy.

If you have questions that aren't answered in the README, then use the Source, Luke. This ain't the Ritz. I didn't write a lot of documentation because it's a bog-simple program that doesn't need documentation.


The current version of fread is fread-1.1. This fixes a really silly bug in 1.0. It also adds a few more seatbelts with error messages, and simplifies slightly the logic in command parsing.

If you want a buggy version for some reason, you can also grab the fread-1.0 release.

That will be all. Carry on.