News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

_vstprintf

Started by czerny, August 15, 2014, 01:30:22 PM

Previous topic - Next topic

czerny

_vstprintf is the TCHAR version of vsprintf resp. vswprintf in VC
   
int _vstprintf(TCHAR *buffer, const TCHAR *format, va_list argptr);

and has 3 parameters.

The Pelles C replacements are 

int _vsnwprintf(wchar_t * restrict dst, size_t max, const char * restrict format, va_list arg);
int vsnprintf(char * restrict dst, size_t max, const char * restrict format, va_list argptr);


with 4 parameters.

Example:


#include <windows.h>
#include <stdio.h>
#include <tchar.h>

void Msg(LPCTSTR pszFormat, ...)
{
   va_list argList;
   va_start(argList, pszFormat);

   TCHAR sz[1024];
   _vstprintf(sz, pszFormat, argList);
   va_end(argList);
   MessageBox(NULL, sz, _T("Pop Msg"), MB_OK);
}

int tmain(int argc, char *argv[])
{
Msg(_T("%d\n"), 5);
return 0;
}

frankie

Pelle changed the destination function:

/* tchar.h - private header for generic text functions */
      ...
#define _vstprintf  vsnprintf  /* 04-10-12: vsprintf -> vsnprintf */
#define _vsntprintf _vsnprintf  /* 04-10-12 */


:(
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide