sprintf相关

 

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

int CDECL MessageBoxPrintf(TCHAR *szCaption, TCHAR *szFormat,)
{
 TCHAR szBuffer[
1024];
 va_list pArgLIST;
 
 va_start(pArgLIST, szFormat);
 
 _vsntprintf(szBuffer, 
sizeof(szBuffer) / sizeof(TCHAR),
          szFormat, pArgLIST);

    TCHAR arr[
20];
 _stprintf(arr, 
"%d"sizeof(szBuffer) / sizeof(TCHAR));
 MessageBox(NULL, arr, 
"gaga"0);
  
 va_end(pArgLIST);
 
return MessageBox(NULL, szBuffer, szCaption, 0);
}


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
       PSTR szCmdLine, 
int iCmdShow)
{
 
int cxScreen, cyScreen;

 cxScreen 
= GetSystemMetrics(SM_CXSCREEN);
 cyScreen 
= GetSystemMetrics(SM_CYSCREEN);

 MessageBoxPrintf(TEXT(
"ScmSize"),
               TEXT(
"The screen is %d pixels wide by %d pixels hight."),
      cxScreen,cyScreen);
 
return 0;
}
   

 

////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////

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

int CDECL MessageBoxPrintf(TCHAR *szCaption, TCHAR *szFormat, );
int CDECL MessageBoxPrintf2(TCHAR *szCaption, TCHAR *szFormat, );

int WINAPI WinMain(__in HINSTANCE hInstance, 
       __in_opt HINSTANCE hPrevInstance, 
       __in_opt LPSTR lpCmdLine, 
       __in 
int nShowCmd )
{
 TCHAR szARR[
20];
 _stprintf(szARR, TEXT(
"%d"), 1);
 MessageBox(NULL, szARR, TEXT(
"1"), 0);

 TCHAR szARR2[
20];
 _sntprintf(szARR2, 
sizeof(szARR2) / sizeof(TCHAR), TEXT("%d"), 2);
 MessageBox(NULL, szARR2, TEXT(
"2"), 0);
    
    MessageBoxPrintf(TEXT(
"3"), TEXT("%d"), 3);

 MessageBoxPrintf(TEXT(
"3"), TEXT("%d"), 4);
 
return 0;
}


int CDECL MessageBoxPrintf(LPTSTR szCaption, LPTSTR szFormat, )
{
 TCHAR szBuffer[
1024];

 va_list PArgList;
    va_start (PArgList, szFormat);
    _vstprintf(szBuffer, szFormat, PArgList);
    va_end (PArgList);
 MessageBox(NULL, szBuffer, szCaption, 
0);
 
return 0;
}


int CDECL MessageBoxPrintf2(LPTSTR szCaption, LPTSTR szFormat, )
{
 TCHAR szBuffer[
1024];
 va_list PArgList;
 va_start (PArgList, szFormat);
 _vsntprintf(szBuffer, 
sizeof(szBuffer) / sizeof(TCHAR), szFormat, PArgList);
 va_end (PArgList);
 MessageBox(NULL, szBuffer, szCaption, 
0);
 
return 0;
}


posted @ 2007-03-26 21:34  Edward Xie  阅读(414)  评论(0)    收藏  举报