Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/f/fscanf.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/f/fscanf.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/f/fscanf.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/f/fscanf.html on line 8
Scan input from a stream
#include <stdio.h>
int fscanf( FILE* fp,
const char* format,
... );
- fp
- The stream that you want to read from.
- format
- A string that specifies the format of the input.
For more information, see
scanf().
The formatting string determines what additional arguments you need to
provide.
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
The fscanf() function scans input from the stream specified by
fp, under control of the argument format.
The number of input arguments for which values were
successfully scanned and stored, or
EOF if the scanning reached the end of the
input stream before storing any values
(errno is set).
Scan a date in the form “Friday March 26 1999”:
#include <stdio.h>
#include <stdlib.h>
int main( void )
{
int day;
int year;
char weekday[10];
char month[10];
FILE *in_data;
in_data = fopen( "file", "r" );
if( in_data != NULL ) {
fscanf( in_data, "%s %s %d %d",
weekday, month, &day, &year );
printf( "Weekday=%s Month=%s Day=%d Year=%d\n",
weekday, month, day, year );
fclose( in_data );
return EXIT_SUCCESS;
}
return EXIT_FAILURE;
}
ANSI,
POSIX 1003.1
Safety: | |
Cancellation point |
Yes |
Interrupt handler |
No |
Signal handler |
No |
Thread |
Yes |
errno,
fwscanf(),
scanf(),
sscanf(),
swscanf(),
vfscanf(),
vfwscanf(),
vscanf(),
vsscanf(),
vswscanf(),
vwscanf(),
wscanf()
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/f/fscanf.html on line 168
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/f/fscanf.html on line 168