'vfprintf func'에 해당되는 글 1건

  1. 2021.11.28 Watcom C Library : _vbprintf, vcprintf, vcscanf, vfprintf

 

 

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( &ltime );

    _localtime( &ltime, &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)

 

 

 

728x90
반응형
Posted by 전화카드
,