En C++, J'ai une variable de tableau de chaîne appelée:Comment récupérer l'élément spécifique d'un tableau de chaînes std :: en tant que LPCSTR?
...
/* set the variable */
string fileRows[500];
...
/* fill the array with a file rows */
while (getline(infile,sIn))
{
fileRows[i] = sIn;
i++;
}
et un objet qui a ceci:
string Data::fileName(){
return (fileRows);
}
Je voudrais faire une fonction qui renvoie un tableau, et après que je voudrais appeler quelque chose comme ceci:
Data name(hwnd);
MessageBox(hwnd, name.fileName(), "About", MB_OK);
Mais je reçois cette erreur:
cannot convert 'std::string* {aka std::basic_string}' to 'LPCSTR {aka const char}' for argument '2' to 'int MessageBoxA(HWND, LPCSTR, LPCSTR, UINT)'
Si je voudrais montrer l'élément 5. du tableau, comment le convertir?
'MessageBox (. Hwnd, name.fileName() c_str(), "A propos", MB_OK);'? – Blake
Quelle est la déclaration pour MessageBoxA? –