CString转Char

来源:互联网 发布:spring eureka golang 编辑:程序博客网 时间:2024/05/16 05:28
method   1   :  
  CString   str("xxx");  
  char*   car   =   new   char[3];  
  sprintf(car,"%s",str);  
  delete   car[];  
  method   2:  
  CString   str("1556666");  
  const   char*   pBuff   =   (char*)(LPCSTR)   str;  
  method   3:  
  CString   str="try";  
  char   *   pBuffer=   new   char[str.GetLenght()+1];   //GetLenght   does   not  
                                                                                                          //   include   the   /0  
  strcpy(pBuffer,str);  
  delete   pBuffer[];