These days with the prevalence of cheap or free databases such as SQLite, MySql and SQL Server 2005 Express, there is less of a need to use random access on binary files. Databases are for another lesson though. In a sense, random access file records is an old fashioned technique but still useful. Serialization is probably more common.
I've used various data handling schemes based on random access files in the past before databases were commonplace. You might want to hold a game map as a file of class objects and fetch the object at location x,y. If the map is say 64 x 64 then the first 64 file records in row 0 hold locations (0,0) to (63,0), the next 64 hold (0,1) to (63,1) and so on. If the sizeof(map_location) is 20 then the whole file is 64*64*20 = 81,920 bytes long.
The example on the next page implements a simple file holding 1000 strings each 10 characters long. Because a fstream can only move the point where you read or write to a particular byte, you have to know where an individual record starts. If the records are the same length then it's a simple multiplication = record number * sizeof (record). If the records are different length then you have to maintain an index. Example 3 uses an index.
On the next page : Another Example of Random Access Files

