If you want to make money online : Register now

Ques : What is Block Input/Output Functions ?

, , No Comments

Block Input / Output functions read/write a block (specific number of bytes from/to a file. A block can be a record, a set of records or an array. These functions are also defined in standard library

• fread( )
• fwrite( )

These two functions allow reading and writing of blocks of data. Their syntax is:

int fread(void *buf, int num_bytes, int count, FILE *fp);
int fwrite(void *buf, int num_bytes, int count, FILE *fp);

In case of fread(), buf is the pointer to a memory area that receives the data from the
file and in fwrite(), it is the pointer to the information to be written to the file.
num_bytes specifies the number of bytes to be read or written. These functions are
quite helpful in case of binary files. Generally these functions are used to read or write
array of records from or to a file. The use of the above functions is shown in the
following program.

0 टिप्पणियाँ:

Post a Comment