CLR 字符转换

CLR 字符转换

转换宏:

1 #define  CLRS2A(x , v) \
2     v  =  ( char   * )(( int )System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(x));
3



应用:

1      char   * ms_tocrl  =   " Hello World! " ;
2     System::String  ^ str  =  gcnew System::String(ms_tocrl);
3      char   * buff;
4     CLRS2A(str,buff);
5     cout << buff;
6      //  printf : Hello World!

你可能感兴趣的:(CLR 字符转换)