C – Binary file Operations

Home/Learn C Programming/C - File/C – Binary file Operations
C – Binary file Operations 2017-08-07T14:26:39+00:00

Binary file Operations :

getw :

getw() function is used to get an integer from a file stream.

Syntax :

int getw(FILE *stream);

putw:

putw() function outputs an integer on a file stream.

Syntax :

int putw(int w, FILE *stream);

C – BINARY FILE OPERATIONS EXAMPLE PROGRAMS :

fwrite :

fwrite() function appends a specified number of equal sized data blocks to an output file.

Syntax :

size_t    fwrite(void *ptr , size_t  size , size_t   n , FILE   *stream);

fread :

fread() function reads specified number of equal sized data blocks from an input file.

Syntax :

size_t   fread(void *ptr , size_t   size , size_t    n , FILE  *stream);

Argument Description
ptr pointer to a block  which  data is read/write.
size length of each item read/write in bytes.
n number of items read/write
stream points to  input/output file stream

 

Prev Next