zoukankan      html  css  js  c++  java
  • System::String^ / std::string / char * 间的转换(部分)

                                  System::String^    to std::string 

                              void MarshalString ( System::String^ s, std::string& os )

     {   
     using namespace System::Runtime::InteropServices;  
     const char* chars = (const char*)(Marshal::StringToHGlobalAnsi(s)).ToPointer(); 
     os = chars; 
     Marshal::FreeHGlobal(IntPtr((void*)chars));
     }
     
                             std::string to System::String^
                             string s="aaaaaaaaaaa";
                             String^ str=gcnew String(s.c_str());
     

                                char *   to  System::String^

                               char *ch="this is char pointer"; 

      String^ str=gcnew String(ch);//  或 :System::Runtime::InteropServices::Marshal::PtrToStringAnsi((IntPtr)ch);

                              

                              std::string to char * 

                               string str="hello";

                               char * ch;

                                ch=str; 

                                 

      

                                    

  • 相关阅读:
    spark
    mongdb
    redis
    mysql
    kylin
    kafka
    hadoop+hive+hbase+kylin
    git
    elasticsearch
    clickhouse
  • 原文地址:https://www.cnblogs.com/KivenLin/p/2711900.html
Copyright © 2011-2022 走看看