//mapName = mapString;//----------------------原始-
string mapName;

CString strtemp,strtemp2;
//char temp[XMAX_FILE_LENGTH + 1];
char temp[1024];

char print_internal_mapname_content[1024];

//数组可以赋值给cstring.   mapName=print_internal_mapname_content;
// 学习用cstring to chars,则需要写代码 cstringTochars(strtemp, temp);
//strcpy(print_internal_mapname_content,temp);数组之间用strcpy
//cstring 之间可以直接赋值 mapName = mapString;

 

vs2008测试

 1 void cstringTochars(CString str, char* chars)
 2 {
 3 #ifdef UNICODE
 4     int n = str.GetLength(); // n = 14, len = 18
 5     int len = WideCharToMultiByte(CP_ACP, 0, str, str.GetLength(), NULL, 0, NULL, NULL);
 6     WideCharToMultiByte(CP_ACP, 0, str, str.GetLength(), chars, len, NULL, NULL);
 7     chars[len+1] = '\0'; //多字节字符以'\0'结束
 8 #else
 9     strcpy(chars, str);
10 #endif
11 }

 

相关文章:

  • 2022-12-23
  • 2021-12-28
  • 2021-09-17
  • 2021-10-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-25
  • 2022-12-23
  • 2021-06-06
  • 2022-01-20
  • 2021-07-12
  • 2021-09-19
  • 2022-12-23
相关资源
相似解决方案