std::vector<LPCWSTR> cpaText; cpaText = {L"Hello World!",L"Your Boy Made His First Window!",L"YEAH"}; int iY = 5; for (int iLoopCounter = 0; iLoopCounter < cpaText.size(); iLoopCounter++, iY += 20) { TextOut(hdc, 5, iY, cpaText[iLoopCounter], _tcslen(cpaText[iLoopCounter])); }
用于后面的复习,因为如果使用 LPCWSTR cpaText[ ]最后会出现指针指向未初始化区域导致崩溃
补充: const WCHAR *s1[] = { L“234”, L"123" }; 可以包含多个字符串, 而 const WCHAR *s1只能定义一个字符串
相关文档:
https://www.runoob.com/w3cnote/cpp-vector-container-analysis.html