以前用sprintf把十进制数用%d格式化到字符串里,一直没什么问题,现在用VS2005,sprintf格式化的字符串没法用MessageBox输出,用wprintf+%d格式化完的字符串里面总是乱码,到底怎么用?都块晕了!大家帮帮我啊!

解决方案 »

  1.   

    不行啊,提示:
    error C2664: 'wsprintfW' : cannot convert parameter 2 from 'const char [4]' to 'LPCWSTR'
      

  2.   

    按楼上改我的代码成这样:
    char str[6];
    wsprintf(str,_T("%d\0"),e);
    MessageBox(pDlg,str,_T("MSG"),MB_OK);
    编译提示:
    wsprintf里不能把str转成LPWSTR
    MessageBox不能把str转为LPWSTR
      

  3.   

    TCHAR str[6];
    wsprintf(str,_T("%d\0"),e);
    MessageBox(pDlg,str,_T("MSG"),MB_OK);
      

  4.   

    2005默认使用unicode编码,把编码格式改为Ansi就可以了