본문 바로가기

IT노트(구)/C/C++

non-MFC 환경에서 CString 사용하는 방법

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