String to LPSTR


#1

How do I convert a JUCE String to an LPString for CreateProcess?


#2

i just figured out that (char *)(const char *)yourString works, but i really have no idea why… :?


#3

that’s cheating really, because casting a String to a non-const char* is a Very Bad Idea.

When you cast a String to a const char*, the pointer is only valid until the String is altered, and it may also be shared between other Strings, as they’re reference counted. If you use that pointer as a non-const string you’re asking for trouble…


#4