在C++中, 我得叫一個字符串數組變量:如何從一個std :: strings數組中檢索特定元素作爲LPCSTR?
...
/* set the variable */
string fileRows[500];
...
/* fill the array with a file rows */
while (getline(infile,sIn))
{
fileRows[i] = sIn;
i++;
}
,並具有這樣的一個對象:
string Data::fileName(){
return (fileRows);
}
我想就其中返回一個數組的函數,從那以後,我想叫它是這樣的:
Data name(hwnd);
MessageBox(hwnd, name.fileName(), "About", MB_OK);
,但我得到這個錯誤:
cannot convert 'std::string* {aka std::basic_string}' to 'LPCSTR {aka const char}' for argument '2' to 'int MessageBoxA(HWND, LPCSTR, LPCSTR, UINT)'
如果我想顯示數組的5.元素,如何轉換它?
'MessageBox(hwnd,name.fileName()。c_str(),「About」,MB_OK);'? – Blake 2013-03-13 21:44:43
MessageBoxA的聲明是什麼? – 2013-03-13 21:46:28