-
2014.12.21 LPCTSTR LPTSTRLegacy/뇌자극 - WinSysProg 2014. 12. 21. 10:36728x901234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253LPSTR CHAR *LPCSTR CONST CHAR *LPWSTR WCHAR *LPCWSTR CONST WCHAR *#ifdef UNICODEtypedef WCHAR TCHAR;typedef LPWSTR LPTSTR;typedef LPCWSTR LPCTSTR;#elsetypedef CHAR TCHAR;typedef LPSTR LPTSTR;typedef LPCSTR LPCTSTR;#endif#ifdef _UNICODE#define __T(x) L ## x#else#define __T(x) x#endif#define _T(x) __T(x)#define _TEXT(x) __T(x)#ifdef _UNIDOCE#define _tmain wmain#define _tcslen wcslen#define _tcscat wcscat#define _tcscpy wcscpy#define _tcsncpy wcsncpy#define _tcscmp wcscmp#define _tcsncmp wcsncmp#define _tprintf wprintf#define _tscanf wscanf#define _fgetts fgetws#define _fputts fputws#else#define _tmain main#define _tcslen strlen#define _tcscat strcat#define _tcscpy strcpy#define _tcsncpy strncpy#define _tcscmp strcmp#define _tcsncmp strncmp#define _tprintf printf#define _tscanf scanf#define _fgetts fgets#define _fputts fputs#endif
cs tchar.h는 windows.h에 포함되지 않음.
최종 예제
123456789101112131415161718192021222324252627282930#define UNICODE#define _UNICODE#include <stdio.h>#include <tchar.h>#include <Windows.h>int _tmain(int argc, TCHAR* argv[]){LPTSTR str1 = _T("MBCS or WBCS 1");TCHAR str2[] = _T("mbcs OR wbcd 2");TCHAR str3[100];TCHAR str4[50];LPCTSTR pStr = str1;_tprintf( _T("string size: %d \n"), sizeof(str2) );_tprintf( _T("string length: %d \n"), _tcslen(pStr) );_fputts(_T("Input String 1 : "), stdout);_tscanf(_T("%s"), str3);_fputts(_T("Input String 2 : "), stdout);_tscanf(_T("%s"), str4);_tcscat(str3, str4);_tprintf( _T("String1 + String2 : %s \n"), str3);return 0;}cs 'Legacy > 뇌자극 - WinSysProg' 카테고리의 다른 글
2015.01.22 커널 오브젝트 Usage Count (0) 2015.01.21 2015.01.20 커널 오브젝트 (0) 2015.01.20 CommandPrmpt_Two.cpp (0) 2015.01.19 CommandPrmpt_One.cpp (0) 2015.01.19 2015.01.19 CreateProcess를 이용한 프로세스 생성 (0) 2015.01.19 2015.01.18 프로세스의 상태 변화 (0) 2015.01.18 2015.01.17 프로세스의 생성과 소멸 (0) 2015.01.17 2015.01.16 LOAD&STORE DIRECT INDIRECT 모드 (0) 2015.01.16 2015.01.13 프로세스, IPC (0) 2015.01.13 2014.12.23 Polymorphic 자료형 (0) 2014.12.23