Problem: How to convert CString into const char * in C++ MFC

后端 未结 5 671
囚心锁ツ
囚心锁ツ 2021-01-21 11:32

How do I convert CString into const char *? I have tried everything found on the internet but I still cant convert them.

Please help.

Thank you.

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-21 11:55

    If your application is not Unicode, you can simple typecast to const char *. Use the GetBuffer() method if you need a char * that you can modify.

    If your application is Unicode and you really want a char *, then you'll need to convert it. (You can use functions like MultiByteToWideChar().)

提交回复
热议问题