How to convert from CString to std::string?

There are really many ways to do it.

But, the simplest one is just this -
CString strSomeCstring ("This is a CString Object");

// Use ANSI variant CStringA to convert to char*; construct from it -
std::string strStdString (CStringA (strSomeCstring));


Note that as discussed in this post, CStringA is a template specialization of class CStringT for type char avaílable with Visual Studio 7.x and better.



CString 을 string 으로 변환할 일이 있었는데 VS 6.0 에서는 먹히던 방법이 VS 2005 에서 안먹히길래 다른 방법을 찾아봤습니다.

구글링을 해보니 금새 나오는군요 ;)

이 글과 관련있는 글을 자동검색한 결과입니다 [?]

by envi | 2008/01/10 15:55 | Develop | 트랙백 | 덧글(1)

트랙백 주소 : http://agstyle.egloos.com/tb/1268876
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]
Commented by 남정현 at 2008/01/12 19:13
VC++에 내장된 STL 구현의 경우 유니코드 버전의 string 클래스가 있어서 CStringW로 캐스팅하는 방법을 통해서 유니코드 문자열로도 캐스팅할 수 있을겁니다.

:         :

:

비공개 덧글

◀ 이전 페이지          다음 페이지 ▶