通过使用wsprintf INT转换为LPCWSTR [英] Convert int to LPCWSTR by using wsprintf
本文介绍了通过使用wsprintf INT转换为LPCWSTR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于以下code:
int a = 16;
wchar_t *buffer = {0};
wsprintf(buffer,L"%d", a);
MessageBox(NULL, buffer, buffer, MB_OK);
我要隐蔽的int LPCWSTR为了把消息框。
我真的很新受使用wsprintf。任何一个可以帮助我,我用这个函数解释清楚? (请,我也看了MSDN,但仍清晰dont't)
I want to covert int to LPCWSTR in order to put MessageBox. I really newbie in using wsprintf. Any one can help me explain clearly for me using this function??? (Please, I also read MSDN but still dont't clear)
我的意思是,我想在MessageBox中打印16
I mean, I want to print "16" in MessageBox
推荐答案
您初始化缓存
到 nullptr
。只要创建为你分配足够的空间 wchar_t的
组成的数组,你是摆脱困境:
You initialize your buffer
to nullptr
. Just create an array of wchar_t
s that allocates enough space for you and you're off the hook:
int a = 16;
wchar_t buffer[256];
wsprintfW(buffer, L"%d", a);
MessageBoxW(nullptr, buffer, buffer, MB_OK);
这篇关于通过使用wsprintf INT转换为LPCWSTR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文