Pelles C forum

Pelles C => Bug reports => Topic started by: czerny on August 15, 2014, 01:30:22 PM

Title: _vstprintf
Post by: czerny 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;
}
Title: Re: _vstprintf
Post by: frankie 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 */

:(