Ques : What is Formatted Input/Output Functions

Ans :

If the file contains data in the form of digits, real numbers, characters and strings, then
character input/output functions are not enough as the values would be read in the
form of characters. Also if we want to write data in some specific format to a file, then
it is not possible with the above described functions. Hence C provides a set of
formatted input/output functions. These are defined in standard library and are
discussed below:

fscanf() and fprintf()

These functions are used for formatted input and output. These are identical to scanf()
and printf() except that the first argument is a file pointer that specifies the file to be
read or written, the second argument is the format string. The syntax for these
functions is:

int fscanf(FILE *fp, char *format,. . .);
int fprintf(FILE *fp, char *format,. . .);

Both these functions return an integer indicating the number of bytes actually read or
written.

Leave a Reply