#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;
}
#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 |