Read a whole file into memory in C

This is an example C program illustrating reading an entire file
into allocated memory. It relies on the Unix system call
stat to get the size of the file. The first call, to get
the size of the file, is also illustrated in this example page:
Get the size of a file in C.