Char * and juce::String

I know it’s my lameness with C++ but:

I have a char * _userName

I have a juce:String uidBox->getText();

How do I convert the juce::String to char * so I can do this:

char _cmd[255];
sprintf(_cmd, “+set name %s”, _userName );

This is the last obstacle to getting my demo out the door.

After hours of trying to find the right Google query to answer this question I found it in Google’s cache.

HOWTO: Convert juce::String to char *

const char * _userName = (char *)(const char *) uidBox->getText();*&hl=en&gl=us&ct=clnk&cd=1

What’s wrong with
const char * _userName = (const char *) uidBox->getText();

But you should be really careful converting strings to char*, and never do it unless there’s absolutely no alternative. The array that’s returned is transient, and will become invalid if the string goes out of scope or changes in any way. This is all explained in the comments for the String class casting operators.