3 /* fscanf( FILE *, const char *, ... )
5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
14 int fscanf( FILE * _PDCLIB_restrict stream, const char * _PDCLIB_restrict format, ... )
18 va_start( ap, format );
19 rc = vfscanf( stream, format, ap );
27 #include <_PDCLIB_test.h>
34 char teststring1[] = " 1 23\045\0\067 ";
37 TESTCASE( ( fh = fopen( "testfile", "w+" ) ) != NULL );
38 TESTCASE( fwrite( teststring1, 15, 1, fh ) == 1 );
41 TESTCASE( memset( buffer, CHAR_MAX, 15 ) == buffer ); \
42 TESTCASE( fseek( fh, 0, SEEK_SET ) == 0 ); \
43 TESTCASE( fscanf( fh, "%14c", buffer ) == 1 ); \
44 TESTCASE( memcmp( buffer, teststring1 + 0, 14 ) == 0 ); \
45 TESTCASE( buffer[ 14 ] == CHAR_MAX ); \
46 TESTCASE( memset( buffer, CHAR_MAX, 15 ) == buffer ); \
47 TESTCASE( sscanf( teststring1 + 14, "%14c", buffer ) ); \
48 TESTCASE( memcmp( buffer, teststring1 + 0, 14 ) == 0 ); \
49 TESTCASE( buffer[ 14 ] == CHAR_MAX );