fread( ): This function reads a specified number of equalsized data items from an input stream into a block, fread returns the number of items (not bytes) actually read on success.
Syntax:
fread (& name_of_structure, size_of_(structure name), l, file pointer); e.g.,
struct employee
{
char nm[20]; /* 20 bytes */
int age; /* 2 bytes */
};
struct employee Emp;
fread (&Emp, size of (Emp), 1, fp);
Here, the fread function can read 22 bytes of information from the file pointed by file pointer fp. fwrite( ): This function appends a specified number of equal-sized data items to an output file.
Syntax:
fwrite (& struct—name, size of (struct), 1, fp); e.g.,
street address
{
char city [30]; /* 30 bytes */
long in pin; /* 2 bytes */
char country [20]; /* 20 bytes */
};
struct address add;
FILE *fp;
fwrite (& add, size of (add), 1, fp);