|
Dieser Artikel wurde maschinell übersetzt. Bewegen Sie den Mauszeiger über die Sätze im Artikel, um den Originaltext anzuzeigen. Weitere Informationen
|
Übersetzung
Original
|
fscanf, _fscanf_l, fwscanf, _fwscanf_l
int fscanf( FILE *stream, const char *format [, argument ]... ); int _fscanf_l( FILE *stream, const char *format, locale_t locale [, argument ]... ); int fwscanf( FILE *stream, const wchar_t *format [, argument ]... ); int _fwscanf_l( FILE *stream, const wchar_t *format, locale_t locale [, argument ]... );
|
|
|
|
|
|---|---|---|---|
|
_ftscanf |
fscanf |
fscanf |
fwscanf |
|
_ftscanf_l |
_fscanf_l |
_fscanf_l |
_fwscanf_l |
|
|
|
|---|---|
|
|
|
|
|
|
// crt_fscanf.c
// compile with: /W3
// This program writes formatted
// data to a file. It then uses fscanf to
// read the various data back from the file.
#include <stdio.h>
FILE *stream;
int main( void )
{
long l;
float fp;
char s[81];
char c;
if( fopen_s( &stream, "fscanf.out", "w+" ) != 0 )
printf( "The file fscanf.out was not opened\n" );
else
{
fprintf( stream, "%s %ld %f%c", "a-string",
65000, 3.14159, 'x' );
// Security caution!
// Beware loading data from a file without confirming its size,
// as it may lead to a buffer overrun situation.
// Set pointer to beginning of file:
fseek( stream, 0L, SEEK_SET );
// Read data back from file:
fscanf( stream, "%s", s ); // C4996
fscanf( stream, "%ld", &l ); // C4996
fscanf( stream, "%f", &fp ); // C4996
fscanf( stream, "%c", &c ); // C4996
// Note: fscanf is deprecated; consider using fscanf_s instead
// Output data read:
printf( "%s\n", s );
printf( "%ld\n", l );
printf( "%f\n", fp );
printf( "%c\n", c );
fclose( stream );
}
}
EinSTRING
65000
3.141590
x System::EA::StreamReader::ReadLine. Siehe auch Parse-Methoden, z. B. System::::doubleAnalyse.