C language library function name: introduction function prototype: size_t fread (void * buffer, size_t size, size_tcount, FILE * stream); Function Ability: read data from a FILE stream, read count elements, each element size byte. if the call is successful, return count. if the call is successful, the actual size * count byte parameter is read: buffer memory address used to receive data, at least size * count bytes. size: the size of a single element. The unit is the number of count elements. Each element is a size byte. stream input stream return value: number of elements actually read. if the returned value is different from count (not count * size), the end of the file may be incorrect. get error information from ferror and feof or check whether it has reached the end of the file. program example # include <stdio. h> # include <string. h> int main (vo Id) {FILE * stream; char msg [] = "this is a test"; char buf [20]; if (stream = fopen ("DUMMY. FIL "," w + ") = NULL) {fprintf (stderr," Cannot open output file. \ n "); return 1;}/* write some data to the file */fwrite (msg, 1, strlen (msg) + 1, stream ); /* seek to the beginning of the file */fseek (stream, 0, SEEK_SET);/* read the data and display it */fread (buf, 1, strlen (msg) + 1, stream); printf ("% s \ n ", Buf); fclose (stream); return 0;} MSDN example # include <stdio. h> void main (void) {FILE * stream; char list [30]; int I, numread, numwritten;/* Open file in text mode: */if (stream = fopen ("fread. out "," w + t "))! = NULL) {for (I = 0; I <25; I ++) list [I] = (char) ('Z'-I ); /* Write 25 characters to stream */numwritten = fwrite (list, sizeof (char), 25, stream); printf ("Wrote % d items \ n", numwritten ); fclose (stream);} else printf ("Problem opening the file \ n"); if (stream = fopen ("fread. out "," r + t "))! = NULL) {/* Attempt to read in 25 characters */numread = fread (list, sizeof (char), 25, stream ); printf ("Number of items read = % d \ n", numread); printf ("Contents of buffer = %. 25s \ n ", list); fclose (stream);} else printf (" File cocould not be opened \ n ");}