前者很常用, 经常被用来转换为字符串或者拼接字符串。
例子:
#include <Windows.h> #include <stdio.h> int main() { int t = 123456; WCHAR str[256] = L"heelo"; wsprintf(&str[5], L"%d", t); wprintf(L"%s", str); return 0; }
结果:
heelo123456
也可以与OutputDebugString配合使用,
WCHAR printData[100]; wsprintf(printData, L"n Event: %dn", meEvent); OutputDebugString(printData);
wvsprintf函数很少见, 下面的例子供参考
#include <Windows.h> #include <stdio.h> void panic(const wchar_t* fmt, ...) { wchar_t buffer[1024]; va_list args = NULL; va_start(args, fmt); wvsprintfW(buffer, fmt, args); va_end(args); MessageBoxW(NULL, buffer, L"error", MB_OK | MB_ICONERROR); ExitProcess(EXIT_FAILURE); } int main() { panic(L"hello, %s!", L"michael"); return 0; }
结果:
原文链接: https://www.cnblogs.com/strive-sun/p/14079537.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍;
也有高质量的技术群,里面有嵌入式、搜广推等BAT大佬
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/404781
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!