Example:
int FAR PASCAL WSAStartup ()
{
char lhstr[20];
char lnstr[20];
LoadString(hInst,1,prstr,20);
LoadString(hInst,5,lnstr,20);
MessageBox(NULL,"name","WSAStartup",MB_OK); // This doesn't work
MessageBox(NULL,lnstr,prstr,MB_OK); // This works
}
THANX
... johnt ...
MessageBox(NULL, (LPCSTR) "name", (LPCSTR) "WSAStartup", MB_OK);
> MessageBox(NULL,lnstr,prstr,MB_OK); // This works
> }
>
>THANX
David
****************************************************************
* David Brabant * E-MAIL : da...@tintin.csl.sni.be *
* Siemens Nixdorf * *
* Centre Software de Liege * Phone : (041) 20.16.09 *
* 2, rue des Fories * *
* 4020 Liege, Belgium * *
****************************************************************
as long as windows.h is dutifully #included the prototype for MessageBox()
should clue the compiler in to the need for a cast. there must be
something els going on here.
-kg
The issue is whether or not the prototype declared the input string
as a const. A const parameter can't be changed by the called routine.
The compiler won't automatically deal with the const issue in the same
way it deals with other conversions.
This routinely pops up when using the STRING and stream classes. Both
of these classes allow you to access the string directly, but in
read only (const) mode. If you attempt to reference the string as a
parameter (to say, printf) without casting it to const, then you get
an error message that is very hard to interpret.
(note that const is the difference between LPCSTR and LPSTR). )
Alan