Reading Data from a File
The data that is written into a file in the form of strings can also be read by using the fgets( ) function.
Syntax
fgets (s, n, fp);
where s is
string
, n is
the maximum length of the input string,
and fp is the
file pointer.
This function reads a string at a time; if it reads the EOF character, it will return a NULL value.
5.4 INTEGER I/O FUNCTIONS
Just as we can read or write data on a character-by-character basis or string-by-string basis, we can
also read and write data in the form of integer numbers.
Writing Data to a File
For writing data in form of integers, we use the putw( ) function:
Syntax
putw (n, fp);
where n is an
integer constant or variable
to be written into a file and fp is a
file pointer.
Reading Data from a File
For reading data from file, use the getw( ) function:
Do'stlaringiz bilan baham: |