_vsnprintf()的一个问题
来源:互联网 发布:js 清除 cookie的方法 编辑:程序博客网 时间:2024/06/13 08:22
最近在看《Windows程序设计(第五版)》 程序2-1 写下来不能运行
#include<Windows.h>#include<tchar.h>#include<stdio.h>int CDECL MessageBoxPrintf(TCHAR *szCaption,TCHAR *szFormat,...){TCHAR szBuffer[1024];va_list pArgList;va_start(pArgList,szFormat);_vsnprintf(szBuffer,sizeof(szBuffer)/sizeof(TCHAR),szFormat,pArgList);va_end(pArgList);return MessageBox(NULL,szBuffer,szCaption,0);}int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR szCmdLine,int iShowCmd){int cxScreen,cyScreen;cxScreen = GetSystemMetrics (SM_CXSCREEN);cyScreen = GetSystemMetrics (SM_CYSCREEN);MessageBoxPrintf(TEXT("Scrnsize"),TEXT("The Screen is i% pixels wide by i% pixels high"),cxScreen,cyScreen);return 0;}
说_vsnprintf()的第一个参数TCHAR *和char *不兼容,不过书上说TCHAR 在有Unicode的时候会变成w_char,否则就是char
TCHAR *难道和 char *不是一个道理吗? 想不通
----------------------------------------------------------------------------------------华丽的分割线-----------------------------------------------------------------------------------------------------------------------------
原来是我傻X了,_vsnprintf()和_vsntprintf()是两个函数,一个是处理char的 一个是处理TCHAR的。大家注意就好~~
可是貌似并没有格式化我的输出,不知道是不是我又傻了
输出是:
The screen is i00000566ixels wide by i00000300ixels high
- _vsnprintf()的一个问题
- “_vsnprintf”: 属性与以前的声明不一致
- error C3163: “_vsnprintf”: 属性与以前的声明不一致
- error C3163: “_vsnprintf”: 属性与以前的声明不一致
- error C3163: “_vsnprintf”: 属性与以前的声明不一致 .
- error C3163: “_vsnprintf”: 属性与以前的声明不一致
- _vsnprintf 用法
- _vsnprintf 用法
- _vsnprintf 用法
- Imagemagick + vs2008 的error C3163: '_vsnprintf': attributes inconsistent with previous declaration 编译错误
- 关于error C3163: '_vsnprintf': attributes inconsistent with previous declaration 编译错误的
- 关于error C3163: '_vsnprintf': attributes inconsistent with previous declaration 编译错误的
- 一个application的问题
- atl的一个问题
- 一个好玩的问题
- 一个opengl的问题
- JexcelAPI的一个问题
- pb的一个问题
- CSS深入理解的学习笔记
- 关于prefereceActivity的addPreferencesFromResource方法在3.0过期问题
- 什么是RSA加密算法?RSA加解密算法破解-Alasend
- ”危险“的restrict与GCC的编译优化
- JAVA学习有感--final修饰符的理解
- _vsnprintf()的一个问题
- SQL关键字之case when
- 运放自激震荡的大杂烩总结
- 容器通过数组初始化
- Codeforces Round #154 (Div. 2)
- Excel 写保护方法
- 如何解决:Android中 Error generating final archive: Debug Certificate expired on 10/09/18 16:30 的错误
- LeetCode : Best Time to Buy and Sell Stock II
- linux中关于lcd的疑惑