Watcom C Library : vfscanf, vprintf, vscanf, vsprintf, vsscanf
Watcom C Reference/T ~ Z 2021. 11. 29. 17:43
Watcom C Library Reference : vfscanf, vprintf, vscanf, vsprintf, vsscanf
vfscanf
Synopsis : #include <stdio.h>
#include <stdarg.h>
int vfscanf( FILE *fp, const char *format, va_list arg );
Description : The vfscanf function scans input from the file designated by fp under control of the argument format. The format string is described under the description of the scanf function.
The vfscanf function is equivalent to the fscanf function, with a variable argument list replaced with arg, which has been initialized using the va_start macro.
Returns : The vfscanf function returns EOF when the scanning is terminated by reaching the end of the input stream. Otherwise, the number of input arguments for which values were successfully scanned and stored is returned. When a file input error occurs, the errno global variable may be set.
See Also : cscanf, fscanf, scanf, sscanf, va_arg, va_end, va_start, vcscanf, vscanf, vsscanf
Example :
#include <stdio.h>
#include <stdarg.h>
void ffind( FILE *fp, char *format, ... )
{
va_list arglist;
va_start( arglist, format );
vfscanf( fp, format, arglist );
va_end( arglist );
}
void main( )
{
int day, year;
char weekday[10], month[12];
ffind( stdin, "%s %s %d %d", weekday, month, &day, &year );
printf( "\n%s, %s %d, %d\n", weekday, month, day, year );
}
Classification : WATCOM
Systems : All
vprintf
Synopsis : #include <stdio.h>
#include <stdarg.h>
int vprintf( const char *format, va_list arg );
Description : The vprintf function writes output to the file stdout under control of the argument format. The format string is described under the description of the printf function. The vprintf function is equivalent to the printf function, with the variable argument list replaced with arg, which has been initialized by the va_start macro.
Returns : The vprintf function returns the number of characters written, or a negative value if an output error occurred. When an error has occurred, errno contains a value indicating the type of error that has been detected.
See Also : _bprintf, cprintf, fprintf, printf, sprintf, va_arg, va_end, va_start, _vbprintf, vcprintf, vfprintf, vsprintf
Example :
The following shows the use of vprintf in a general error message routine.
#include <stdio.h>
#include <stdarg.h>
void errmsg( char *format, ... )
{
va_list arglist;
printf( "Error: " );
va_start( arglist, format );
vprintf( format, arglist );
va_end( arglist );
}
void main( )
{
errmsg( "%s %d %s", "Failed", 100, "times" );
}
Classification : ANSI
Systems : All
vscanf
Synopsis : #include <stdio.h>
#include <stdarg.h>
int vscanf( const char *format, va_list arg );
Description : The vscanf function scans input from the file designated by stdin under control of the argument format. The format string is described under the description of the scanf function.
The vscanf function is equivalent to the scanf function, with a variable argument list replaced with arg, which has been initialized using the va_start macro.
Returns : The vscanf function returns EOF when the scanning is terminated by reaching the end of the input stream. Otherwise, the number of input arguments for which values were successfully scanned and stored is returned.
See Also : cscanf, fscanf, scanf, sscanf, va_arg, va_end, va_start, vcscanf, vfscanf, vsscanf
Example :
#include <stdio.h>
#include <stdarg.h>
void find ( char *format, ... )
{
va_list arglist;
va_start( arglist, format );
vscanf( format, arglist );
va_end( arglist );
}
void main( )
{
int day, year;
char weekday[10], month[12];
find( "%s %s %d %d", weekday, month, &day, &year );
printf( "\n%s, %s %d, %d\n", weekday, month, day, year );
}
Classification : WATCOM
Systems : All
vsprintf
Synopsis : #include <stdio.h>
#include <stdarg.h>
int vsprintf( char *buf, const char *format, va_list arg );
Description : The vsprintf function formats data under control of the format control string and writes the result to buf. The format string is described under the description of the printf function. The vsprintf function is equivalent to the sprintf function, with the variable argument list replaced with arg, which has been initialized by the va_start macro.
Returns : The vsprintf function returns the number of characters written, or a negative value if an output error occurred.
See Also : _bprintf, cprintf, fprintf, printf, sprintf, va_arg, va_end, va_start, _vbprintf, vcprintf, vfprintf, vprintf
Example :
The following shows the use of vsprintf in a general error message routine.
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
char msgbuf[80];
char *fmtmsg( char *format, ... )
{
va_list arglist;
va_start( arglist, format );
strcpy( msgbuf, "Error: " );
vsprintf( &msgbuf[7], format, arglist );
va_end( arglist );
return( msgbuf );
}
void main( )
{
char *msg;
msg = fmtmsg( "%s %d %s", "Failed", 100, "times" );
printf( "%s\n", msg );
}
Classification : ANSI
Systems : All
vsscanf
Synopsis : #include <stdio.h>
#include <stdarg.h>
int vsscanf( const char *in_string, const char *format, va_list arg );
Description : The vsscanf function scans input from the string designated by in_string under control of the argument format. The format string is described under the description of the scanf function.
The vsscanf function is equivalent to the sscanf function, with a variable argument list replaced with arg, which has been initialized using the va_start macro.
Returns : The vsscanf function returns EOF when the scanning is terminated by reaching the end of the input string. Otherwise, the number of input arguments for which values were successfully scanned and stored is returned.
See Also : cscanf, fscanf, scanf, sscanf, va_arg, va_end, va_start, vcscanf, vfscanf, vscanf
Example :
#include <stdio.h>
#include <stdarg.h>
void sfind( char *string, char *format, ... )
{
va_list arglist;
va_start( arglist, format );
vsscanf( string, format, arglist );
va_end( arglist );
}
void main( )
{
int day, year;
char weekday[10], month[12];
sfind( "Saturday April 13 1999", "%s %s %d %d", weekday, month, &day, &year );
printf( "\n%s, %s %d, %d\n", weekday, month, day, year );
}
Classification : WATCOM
Systems : All
This manual describes the WATCOM C library for DOS, Windows, and OS/2, It includes the Standard C Library (as defined in the ANSI C Standard).
WATCOM C Language Reference manual describes the ANSI C Programming language and extensions to it which are supported by WATCOM C/C++ (32bit)
'Watcom C Reference > T ~ Z' 카테고리의 다른 글
Watcom C Library : wait, wcstombs, wctomb, _wrapon, write (0) | 2021.12.01 |
---|---|
Watcom C Library : _vbprintf, vcprintf, vcscanf, vfprintf (0) | 2021.11.28 |
Watcom C Library : utime, utoa, va_arg, va_end, va_start (0) | 2021.11.26 |
Watcom C Library : umask, ungetc, ungetch, unlink, unlock, _unregisterfonts (0) | 2021.11.23 |
Watcom C Library : tmpnam, tolower, toupper, tzset, ultoa (0) | 2021.11.22 |
Watcom C Library : tan, tanh, tell, time, tmpfile (0) | 2021.11.20 |