티스토리 뷰


#include <stdio.h>
#include <msclr/marshal.h>

using namespace System;
using namespace msclr::interop;

int main(array<System::String ^> ^args)
{
    {
        // System::String^ to const char*
        marshal_context^ context = gcnew marshal_context();
        String^ message = gcnew String("System::String^ to const char*");
        const char* result = context->marshal_as<const char*>(message);
        puts(result);
        delete context;
    }

    {
        // const char* to System::String^
        const char* message = "const char* to System::String^";
        String^ result = marshal_as<String^>(message);
        Console::WriteLine(result);
    }

    return 0;
}


'Code > C C++' 카테고리의 다른 글

Display Number on Tray Icon  (0) 2010.06.20
[C++] polymorphism.h  (0) 2010.05.17
[C++] How to: Convert Between Various String Types  (0) 2010.05.17
[C++] vector shared_ptr sample  (0) 2010.05.15
[MFC] Simplified MFC Structure  (0) 2010.04.24
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함