This documentation is archived and is not being maintained.

CStringT::FormatV 

Formats a message string using a variable argument list.


void FormatV(
   PCXSTR pszFormat,
   va_list args
);

Parameters

pszFormat

Points to the format-control string. It will be scanned for inserts and formatted accordingly. The format string is similar to run-time function printf-style format strings, except it allows for the parameters to be inserted in an arbitrary order.

args

Pointer to a list of arguments.

Writes a formatted string and a variable list of arguments to a CStringT string in the same way that vsprintf formats data into a C-style character array.

// cstringt_formatv.cpp
#include <string.h>
#include <atlsimpstr.h>
#include <atlstr.h>

void WriteString(LPCSTR pstrFormat, ...)
{
    CString str;

    // format and write the data you were given
    va_list args;
    va_start(args, pstrFormat);

    str.FormatV(pstrFormat, args);
    va_end(args);

    printf_s(str);
    return;
}

int main( )
{
     WriteString("%d error(s) found in %d line(s)", 10, 1351);
}

Output

10 error(s) found in 1351 line(s)
Show: