write formatted output directly to the console
#include <conio.h> #include <stdarg.h> int vcprintf( const char *format, va_list arg );
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.
The number of characters written, or a negative value if an output error occurred. When an error has occurred, errno indicates the type of error detected.
#include <conio.h> #include <stdarg.h> #include <time.h> #define ESCAPE 27 void tprintf( int row, int col, char *format, ... ) { 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; char buf[26]; time( <ime ); _localtime( <ime, &time_of_day ); tprintf( 12, 1, "Date and time is: %s\n", _asctime( &time_of_day, buf ) ); }
WATCOM
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
_bprintf(), cprintf(), fprintf(), printf(), putch(), sprintf(), va_arg(), va_end(), va_start(), _vbprintf(), vfprintf(), vprintf(), vsprintf()