textEdit->Text to LPTSTR

Hello,

Could anyone give me an example of how to convert from a System::String to LPTSTR?

Thank you very much
aureliuhAsked:
Who is Participating?
 
AlexFMConnect With a Mentor Commented:
#include <atlstr.h>
...

    String^ s = L"test";
    CString s1(s);

    LPTSTR s2 = (LPTSTR)(LPCTSTR)s1;

CStringT class has constructor which accepts String^. Then CStringT is casted to LPTSTR. This code doesn't require MFC dependency.
0
 
aureliuhAuthor Commented:
Thank you very much! It really helped me.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.