我正在將變數的值列印到DebugView。
除了手動指定% VarTYPE
目前是這樣做的:
WCHAR wsText[255] = L""/span>。
wsprintf(wsText, L "dwExStyle: %?? lpClassName: lpWindowName: %??? ...", dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, ...)。)
return CreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)。
它不一定是wsprintf,能夠列印它而不需要手動指定每個引數型別會有幫助!
uj5u.com熱心網友回復:
是的,使用字串流,它們也比wsprintf更安全(緩沖區超限)。對于未知型別,你可以多載運算子<<。
#include <Windows.h>/span>
#include <string>
#include <sstream>
int main()
{
DWORD dwExStyle{ 0 }。
std::wstringstream wss;
wss << L "dwExtStyle : " << dwExStyle << , lpClassName: "; // and more....
OutputDebugString(wss.str().c_str() )。
}
std::ostream& operator<<(std::ostream& os, const your_type& value)
{
os << value.member; //或其他。
return os。
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/320284.html
標籤:
