I want to change a wxString to char*, then I can use:
wxString strTemp;
const char* pz = strTemp.c_str();
const char* pz = strTemp.char_str();
const char* pz = strTemp.mb_str();
const char* pz = strTemp.ToAsicc();
...
but I find aboving methods all return a "\0\0....somechar..."
under CodeBlocks(my OS is ubuntu), only this way:
char temp[40];
strcpy(temp,strTemp.mb_str());
const char* a_pszFile = temp;
can return the right char*.
Does anyone have some better method? And more important is please explain the difference between these methods, tks.
wxString convert to char*, so weird! Topic is solved
wxString convert to char*, so weird!
My brother is going to go to university.
-
- Super wx Problem Solver
- Posts: 264
- Joined: Mon Aug 07, 2006 3:25 pm
- Location: Baia Mare, Romania
- Contact:
You could try
It's the best way to convert to "const char *" since the operator is overloaded.
Regards
Code: Select all
wxString sStr("test");
const char * pSz = (const char *) sStr;
wxString * pStr = new wxString("test");
const char * pSz1 = (const char *) *pStr;
Regards
Software is like sex,
It's better when it's free.
~Linus Torvalds
It's better when it's free.
~Linus Torvalds