c++ - Converting form CString to const char* -
i've wrote method convert form cstring
const char *
:
const char* caesdlg::converttochar(cstring str) { cstringa charstr(str); const char *cstr = (const char *)charstr; return cstr; }
but when trying put in const char *
doesn't return correct value!
const char *test = converttochar(filepath);
the value of charstr
gets destroyed @ end of function before caller assigns variable.
you don't need function, caller can use cstringa
directly , note test
valid before sfilepatha
goes out of scope.
cstringa sfilepatha(filepath); const char *test = sfilepatha;
Comments
Post a Comment