C language fscanf () function: Input function (more commonly used)
header file:
To define a function:
int fscanf (FILE * stream, const char *format, ...);
Function Description: fscanf () reads the string from the file stream in the parameter stream, and then converts and formats the data based on the parameter format string. Please refer to scanf () for the format conversion form. The converted structure is stored in the corresponding parameter.
Return value: Returns the number of parameters for success, failure returns 1, and the reason for the error is in errno.
Example
#include <stdio.h>
Main ()
{
int i;
unsigned int J;
Char s[5];
FSCANF (stdin, "%d%x%5[a-z]%*s%f", &i, &j, S, s);
printf ("%d%d%s \ n", I, J, s);
}
Perform:
0x1b aaaaaaaaa bbbbbbbbbb//from keyboard input
AAAAA
C language vfscanf () function: Input function (format string before entering)
header file:
To define a function:
int vfscanf (FILE * stream, const char * format, va_list AP);
Function Description: VFSCANF () reads the string from the file stream in the parameter stream, and then converts and formats the data based on the parameter format string. Please refer to scanf () for the format conversion form. The converted results are stored in the corresponding parameters. Please refer to Appendix C or vprintf () for va_list usage.
Return value: Returns the number of parameters for success, failure returns 1, and the reason for the error is in errno.