non-MFC 환경에서 CString을 사용하려면
atlstr.h를 include하면 된다!(CString을 사용하기 위한 위대한 투쟁이지 않은가?)
예제는 다음과 같다!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 |
#include <iostream>
#include <tchar.h>
#include <atlstr.h> // 이 헤더를 추가하면 된다!
int main(void)
{
CString strTest(_T("Hello World"));
#ifdef UNICODE
std::wcout << (LPCTSTR)strTest << std::endl; // 유니코드
#else
std::cout << (LPCTSTR)strTest << std::endl; // 멀티바이트
#endif
getchar();
return 0;
} |
cs |
'IT노트(구) > C/C++' 카테고리의 다른 글
std::string을 char array로 변환하는 방법 (0) | 2016.01.04 |
---|---|
LPCSTR을 LPCWSTR로 변환하는 방법 (0) | 2015.12.31 |
'vector' : 선언되지 않은 식별자입니다. - 해결 방법 (0) | 2015.12.22 |
printf()와 puts()의 차이점 (0) | 2015.12.21 |
std::cout으로 string이 출력되지 않을 경우 해결 방법 (0) | 2015.11.22 |