Write a program to updating random access file

The file needs to be opened for updating (i.e., to allow both reading and writing).

That’s what the part is unnecessary but still recommended for clarity on Unix and Unix-like systems—however, it’s absolutely crucial on other platforms, such as Macintosh and Windows).

For that reason and the fact that random access on a text file isn't something you need to do often, this tutorial is limited to binary files.

The first four operations listed above are for both text and random access files. Random access means you can move to any part of a file and read or write data from it without having to read through the entire file.

The following program open a random-access file, define a record format using a struct, write data to the disk and close the file.