Watcom C Library : _vbprintf, vcprintf, vcscanf, vfprintf
Watcom C Reference/T ~ Z 2021. 11. 28. 20:28
Watcom C Library Reference : _vbprintf, vcprintf, vcscanf, vfprintf
_vbprintf
Synopsis : #include <stdio.h>
#include <stdarg.h>
int _vbprintf( char *buf, unsigned int bufsize, const char *format, va_list arg );
Description : The _vbprintf function formats data under control of the format control string and writes the result to buf. The argument bufsize specifies the size of the character array buf into which the generated output is placed. The format string is described under the description of the printf function. The _vbprintf function is equivalent to the _bprintf function, with the variable argument list replaced with arg, which has been initialized by the va_start macro.
Returns : The _vbprintf 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, vcprintf, vfprintf, vprintf, vsprintf
Example :
The following shows the use of _vbprintf 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: " );
_vbprintf( &msgbuf[7], 73, format, arglist );
va_end( arglist );
return( msgbuf );
}
void main( )
{
char *msg;
msg = fmtmsg( "%s %d %s", "Failed", 100, "times" );
printf( "%s\n", msg );
}
Classification : WATCOM
Systems : All
vcprintf
Synopsis : #include <conio.h>
#include <stdarg.h>
int vcprintf( const char *format, va_list arg );
Description : The vcprintf function writes output directly to the console under control of the argument format. The putch function is used to output characters to the console. The format string is described under the description of the printf function. The vcprintf function is equivalent to the cprintf function, with the variable argument list replaced with arg, which has been initialized by the va_start macro.
Returns : The vcprintf 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, vfprintf, vprintf, vsprintf
Example :
#include <conio.h>
#include <stdarg.h>
#include <time.h>
#define ESCAPE 27
void tprintf( int row, int col, char *format, ... )
{
auto va_list arglist;
cprintf( "%c (%2.2d; %2.2dH", ESCAPE, row, col );
va_start( arglist, format );
vcprintf( format, arglist );
va_end( arglist );
}
void main( )
{
struct tm time_of_day;
time_t ltime;
auto char buf[26];
time( <ime );
_localtime( <ime, &time_of_day );
tprintf( 12, 1, "Date and time is: %s\n", _asctime( &time_of_day, buf ) );
}
Classification : WATCOM
Systems : All
vcscanf
Synopsis : #include <conio.h>
#include <stdarg.h>
int vcscanf( const char *format, va_list args )
Description : The vcscanf function scans input from the console under control of the argument format. The vcscanf function uses the function getche to read characters from the console. The format string is described under the description of the scanf function.
The vcscanf function is equivalent to the cscanf function, with a variable argument list replaced with arg, which has been initialized using the va_start macro.
Returns : The vcscanf 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, vfscanf, vscanf, vsscanf
Example :
#include <conio.h>
#include <stdarg.h>
void cfind( char *format, ... )
{
va_list arglist;
va_start( arglist, format );
vcscanf( format, arglist );
va_end( arglist );
}
void main( )
{
int day, year;
char weekday[10], month[12];
cfind( "%s %s %d %d", weekday, month, &day, dyear );
cprintf( "\n%s, %s %d, %d\n", weekday, month, day, year );
}
Classification : WATCOM
Systems : All
vfprintf
Synopsis : #include <stdio.h>
#include <stdarg.h>
int vfprintf( FILE *fp, const char *format, va_list arg );
Description : The vfprintf function writes output to the file pointed to by fp under control of the argument format. The format string is described under the description of the printf function. The vfprintf function is equivalent to the fprintf function, with the variable argument list replaced with arg, which has been initialized by the va_start macro.
Returns : The vfprintf 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, vprintf, vsprintf
Example :
#include <stdio.h>
#include <stdarg.h>
FILE *LogFile;
/* a general error routine */
void errmsg( char *format, ... )
{
va_list arglist;
fprintf( stderr, "Error: " );
va_start( arglist, format );
vfprintf( stderr, format, arglist );
va_end( arglist );
if( LogFile != NULL ) {
fprintf( LogFile, "Error: " );
va_start( arglist, format );
vfprintf( LogFile, format, arglist );
va_end( arglist );
}
}
void main( )
{
LogFile = fopen( "error.log", "w" );
errmsg( "%s %d %s", "Failed", 100, "times" );
}
Classification : ANSI
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 : vfscanf, vprintf, vscanf, vsprintf, vsscanf (0) | 2021.11.29 |
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 |