August 14th, 2003, 09:26 AM
String to LPCSTR
Is there a way to convert a String to an LPCSTR?
I use this code:
and get this error:
error C2440: 'Typcasting': 'System::String __gc *' cannot be converted to 'LPCSTR'
August 14th, 2003, 11:25 AM
There should be a function in the text object to convert to a char * (which is basically what the LPCSTR is (Long Pointer to C STRing, if I recall correctly)), just search your documentation.
August 14th, 2003, 02:21 PM
I think its:
LPCSTR szString = "Orange";
String *sString = new String(szString);
August 14th, 2003, 02:24 PM
My bad, the other way around its:
LPCTSTR szString = NULL;
szString = (LPCTSTR)(System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(textBox1->Text).ToPointer());
CopyFile(szString, "c:\ttest.dat", true);
August 15th, 2003, 01:15 AM
And again I say:"Thank you very much Nem!!!!!!!!"