The general form of fprintf is:-
fprintf(fp, “control string”, list)
eg:-
fprintf(f1, “%s %d %f”, name, age, 7.5);
Name is an array variable of type char and age is an int variable. The function fprintf will cause the value name age and 7.5 to be written to the file pointed by variable f1.
The general format of fscanf is
fscanf(fp, “control string”, list);
This statement would cause the reading of the items in the list from the file specified by fp, according to the specifications contained in the control string.
eg.
fscanf(f2, “%s %d”, item, & quantity);
Like scanf fscanf also returns number of items that are successfully read. When the end of the file is reached, it returns the value EOF.
fprintf(fp, “control string”, list)
eg:-
fprintf(f1, “%s %d %f”, name, age, 7.5);
Name is an array variable of type char and age is an int variable. The function fprintf will cause the value name age and 7.5 to be written to the file pointed by variable f1.
The general format of fscanf is
fscanf(fp, “control string”, list);
This statement would cause the reading of the items in the list from the file specified by fp, according to the specifications contained in the control string.
eg.
fscanf(f2, “%s %d”, item, & quantity);
Like scanf fscanf also returns number of items that are successfully read. When the end of the file is reached, it returns the value EOF.