이 글의 문맥을 분석하여 이글루스에 있는 많은 글 중에서 관련성이 높은 글을 자동으로 검색해 낸 결과입니다.
 
angelgrd.egloos.com
Egloos | Log-in

 
by 셀린™
카테고리
전체
프로그래밍
WinCE
WinPE
테크닉
참고자료
음악
잡담
미분류
이전블로그
more...
이글루링크
로리버드의 이런저런 사..
뚝딱뚝딱 작업방
최근 등록된 덧글
궁금한데요 // 님 덕분에..
by 셀린™ at 04/09
궁금한데요 // 관심 밖. ..
by 셀린™ at 03/26
혹시 찾고 있는 자료가 ..
by doekhdk at 03/19
직업이 프로그래머 아니..
by 궁금한데요 at 02/27
혹시님 // MS 공식 한글 ..
by 셀린™ at 12/16
혹시 MS 공식 한글 FP은..
by 혹시 at 11/25
이런 님// 해당 파일이 있..
by 셀린™ at 10/13
자세히좀 알려주세요 뭐..
by 이런 at 09/27
64비트 사용하시는 분은 ..
by 셀린™ at 07/30
부연설명 해야 할 것으로..
by 셀린™ at 07/24
Powered by egloos
rss

skin by 이글루스
문자열 형식간 변환 3. _bstr_t 에서 변환 예제
// convert_from_bstr_t.cpp
// compile with /clr /link comsuppw.lib

#include <iostream>
#include <stdlib.h>
#include <string>

#include "atlbase.h"
#include "atlstr.h"
#include "comutil.h"

using namespace std;
using namespace System;

//===========================================================================
int main()
//===========================================================================
{

 _bstr_t   orig("Hello, World!");
 wcout << orig << " (_bstr_t)" << endl;

 // Convert to a char*
 const size_t newsize = 100;
 char   nstring[newsize];
 strcpy_s(nstring, (char *)orig);
 strcat_s(nstring, " (char *)");
 cout << nstring << endl;

 // Convert to a wchar_t*
 wchar_t   wcstring[newsize];
 wcscpy_s(wcstring, (wchar_t *)orig);
 wcscat_s(wcstring, L" (wchar_t *)");
 wcout << wcstring << endl;

 // Convert to a CComBSTR
 CComBSTR  ccombstr((char *)orig);
 if (ccombstr.Append(L" (CComBSTR)") == S_OK)
 {
  CW2A  printstr(ccombstr);
  cout << printstr << endl;
 }

 // Convert to a CString
 CString   cstring((char *)orig);
 cstring += " (CString)";
 cout << cstring << endl;

 // Convert to a basic_string
 string   basicstring((char *)orig);
 basicstring += " (basic_string)";
 cout << basicstring << endl;

 // Convert to a System::String
 String ^systemstring = gcnew String((char *)orig);
 systemstring += " (System::String)";
 Console::WriteLine("{0}", systemstring);
 delete systemstring;
}

출력
Hello, World! (_bstr_t)
Hello, World! (char *)
Hello, World! (wchar_t *)
Hello, World! (CComBSTR)
Hello, World! (CString)
Hello, World! (basic_string)
Hello, World! (System::String)

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

  • 문자열 형식간 변환 1. char* 에서 변환 예제 by 셀린™
  • C++ 파일 입출력 by Ego君
  • std::map 초기화 해주나? by 샘이
  • std::map에서 초기화 해준다. by 샘이
# by 셀린™ | 2007/02/14 13:06 | 프로그래밍 | 트랙백
트랙백 주소 : http://angelgrd.egloos.com/tb/924345
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]
※ 로그인 사용자만 덧글을 남길 수 있습니다.
<< 이전 페이지 다음 페이지 >>
이글루링크 추가하기
()을(를)
이글루링크로 추가하시겠습니까? 추가하시려면 그룹선택을 하세요.
(그룹선택 하지 않는 경우, 최상단 목록에 추가됩니다.)
그룹선택 :
이글루링크 취소