Return to Website

C++ / VC++ / MFC Discussion Forum

Welcome to the forum. Now, you can use HTML in your posts too.

C++ / VC++ / MFC Discussion Forum
Start a New Topic 
Author
Comment
Need help about string convert from CString to char point

Hi,
I am trying to convert from CString to char point. I tried your code, but when I use system command, it doesn't work. Please help. Thanks.
..............
//Doesn't work
CString MyString = "c:userstest.txt";
char * szMyString = (char *) (LPCTSTR) MyString;
system(szMyString);
................
//this one Works, but my string is CString
char * szMyString="c:userstest.txt"; //good code
system(szMyString); //good code

Re: Need help about string convert from CString to char point

Hi friend,
Try this,
CString str = "Hi friend";
char str2[100];
strcpy(str2,(LPCTSTR)str);

also include

bye