cstring的话 就比较方便了现在在win32 下  用哪个呢?char *imgeFileName = "111";
char *imgeFileName2 = "2222";
strcat(imgeFileName,imgeFileName2);MessageBox((LPCTSTR)imgeFileName,L"标题",64);这样会出错

解决方案 »

  1.   

    char imgeFileName[10] = "111";
      

  2.   

    char *imgeFileName = "111";
    char *imgeFileName2 = "2222";
    strcat(imgeFileName,imgeFileName2);
    -------------------------------------

    指针指向字符串常量,不允许改变其内容
      

  3.   

    char imgeFileName[8] = "111";
    char imgeFileName2[5] = "2222";
    strcat(imgeFileName,imgeFileName2);
      

  4.   

    最好用string:#include <string>
    using namespace std;
    ...
    ...
    ...string imageFileName = "111";
    string imageFileName2 = "2222";
    imageFileName += imageFileName2;MessageBox((LPCTSTR)imageFileName.c_str(),L"标题",64);
      

  5.   

    遇到这种事情,我一般是是用CString
      

  6.   

    char *imgeFileName = "111";
    char *imgeFileName2 = "2222";
    strcat(imgeFileName,imgeFileName2);strcat函数执行会出错的,imgeFileName和imgeFileName2指针已经分配了固定的内存空间(指向了字符串常量),就不许更改了,如果不用CString,可以用std中的string.
      

  7.   

    现在我很依赖ATL的CString不错。
      

  8.   


    char imgeFileName[8] = "111";
    char imgeFileName2[5] = "2222";
    strcat(imgeFileName,imgeFileName2);
    MessageBox((LPCTSTR)imgeFileName,L"标题",64);
    为什么乱码呢?
      

  9.   


    因为编码格式不同wchar_t imgeFileName[8] = L"111";
    wchar_t imgeFileName2[5] = L"2222";
    wcscat(imgeFileName,imgeFileName2);
    MessageBox((LPCTSTR)imgeFileName,L"标题",64);这样全用宽字符应该就没问题了
      

  10.   

    strcat 微软不都不推荐使用这些字符串处理函数了吗?