function
<cstdio>
vfscanfint vfscanf ( FILE * stream, const char * format, va_list arg );
Read formatted data from stream into variable argument list
Reads data from the stream and stores them according to parameter format into the locations pointed by the elements in the variable argument list identified by arg.Internally, the function retrieves arguments from the list identified by arg as if va_arg was used on it, and thus the state of arg is likely to be altered by the call.
In any case, arg should have been initialized by va_start at some point before the call, and it is expected to be released by va_end at some point after the call.
If a reading error happens or the end-of-file is reached while reading, the proper indicator is set (feof or ferror). And, if either happens before any data could be successfully read, EOF is returned.
If an encoding error happens interpreting wide characters, the function sets errno to EILSEQ.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* vfscanf example */
#include <stdio.h>
#include <stdarg.h>
void ReadStuff (FILE * stream, const char * format, ...)
{
va_list args;
va_start (args, format);
vfscanf (stream, format, args);
va_end (args);
}
int main ()
{
FILE * pFile;
int val;
char str[100];
pFile = fopen ("myfile.txt","r");
if (pFile!=NULL) {
ReadStuff ( pFile, " %s %d ", str, &val );
printf ("I have read %s and %d", str, val);
fclose (pFile);
}
return 0;
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4