Reading in files is almost the same as writing to files—just the opposite. When we were writing to files earlier, we passed a string as a parameter that contained the data in the file. When we read in files, the reading function returns a string that we can manipulate for our purposes.
So what is the reading function, then? If you’ve been paying attention, you can probably guess the name: fread(). Take a look at the function declaration:
Both of these parameters are required. The first parameter is the handle to the file we retrieved by using fopen(). The second parameter is the number of bytes you wish to retrieve. fread() only works for pages that have been opened for reading access. ...