Usage of fscanf

The read and write objects of fprintf and fscanf are not terminals but disk files;

The calling method is: int fprintf (file pointer, format string, output table column) return value: return The actual number of characters output,

If the operation is unsuccessful, EOF will be returned

int fscanf (file pointer, format string, input table column) return value: Returns the number of input data, operation If unsuccessful, return EOF

fprintf(fp, "%d, %6.2f", i, t) Output the values ??of integer variable i and real variable t in the format of %d and %6.2f to the file pointed to by fp; If i=3, t=4.5, the format output to the disk is: 3, 4.50. Correspondingly, when reading data from the file, apply: fscanf(fp, "%d , %f", &i, &t)

When using fprintf and fscanf, the delimiters should be consistent when outputting data to the file and reading data from the file. As shown in the following program, the function of the program is: the user inputs 8 integer data, the program echoes and writes the data to the int.txt file, and then the program reads the data from the int.txt file and displays it.