Thứ Tư, 13 tháng 7, 2011

Convert CString to std::string and vice versa in MFC

Hi all,
Today i return my blog and i want to be able to tell about converting kinds of data.
Do you know how to convert between CString and std::string?
This is very important for progamming with MFC application.
There are many ways to do this but i will introduce one of them.
If you want to convert from std::string to CString, you can use syntax:

std::string   demo("You are welcome!");
CString convert;
convert(demo.c_str());


And if you want to convert vice versa, you can do the following:

CString demo("You are welcome!");
std::string convert;
// If you don't use Unicode format
convert((LPCTSTR)demo);
// If you use Unicode format
CT2CA  temp(demo);
convert(temp);



I hope you will succeed. Thanks for visiting my blog!
Do your best, the rest will come.

Không có nhận xét nào:

Đăng nhận xét

Install Kubernetes using kubeadm with two nodes master & worker

Well come back for a long time my friends! Today I want to take a note about some basic knowledge about Kubernetes. I hope that it will...