NO

Author Topic: _vstprintf  (Read 3404 times)

czerny

  • Guest
_vstprintf
« on: August 15, 2014, 01:30:22 PM »
_vstprintf is the TCHAR version of vsprintf resp. vswprintf in VC
   
Code: [Select]
int _vstprintf(TCHAR *buffer, const TCHAR *format, va_list argptr);
and has 3 parameters.

The Pelles C replacements are 

Code: [Select]
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:

Code: [Select]
#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;
}

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: _vstprintf
« Reply #1 on: August 15, 2014, 05:21:41 PM »
Pelle changed the destination function:
Code: [Select]
/* 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