swprintf(str,TEXT("%d is %c"),i+1,'A'+i);
TextOut(hdc,0,20*i,str,strlen(str));错误:'swprintf': swprintf has been changed to conform with the ISO C standard, adding an extra character count parameter. To use traditional Microsoft swprintf, set _CRT_NON_CONFORMING_SWPRINTFS.
请教下怎么回事?
我用sprintf 时类型不行
用swprintf还得用text
上次还行 这次怎么就不行了 急求 后面编不下去了

解决方案 »

  1.   

    我用sprintf 时类型不行
    ==错误提示是什么?哪个类型不行?
      

  2.   

    sprintf(str, _T("%d is %c"), i+1, 'A'+i);
    ...
      

  3.   


    应该为
    swprintf(str,L"%d is %c",i+1,'A'+i);
      

  4.   


    我构造个字符串 但是报错???
    错误是这个: 'swprintf': swprintf has been changed to conform with the ISO C standard, adding an extra character count parameter. To use traditional Microsoft swprintf, set _CRT_NON_CONFORMING_SWPRINTFS.
    伤不起啊。
    大神帮我调下吧,谢了!
      

  5.   

    'swprintf': swprintf has been changed to conform with the ISO C standard, adding an extra character count parameter. To use traditional Microsoft swprintf, set _CRT_NON_CONFORMING_SWPRINTFS翻译过来是swprintf 已被替换成ISO C定义的标准函数,多了一个缓冲区长度的参数。
    如果需要使用传统的微软定义的 swprintf,请定义宏 _CRT_NON_CONFORMING_SWPRINTFS顺便提一句
    新函数为 int swprintf_s(wchar_t *buffer, size_t sizeOfBuffer, const wchar_t *format, ...);
    处于缓冲区溢出的危险的考虑,
    多了第2个参数,表示 第1个参数的最大长度。这本来是一个警告,你编译器设置应该是把警告做为错误处理了。
    本意是告诉你,sprintf系列函数有新的、更安全的版本。
    你定义了宏 _CRT_NON_CONFORMING_SWPRINTFS之后,
    表示你坚持用旧的、有危险的版本,
    微软已经尽到了通知的责任,出问题它不管了。
      

  6.   

    总之 你要么在文件的最前面定义宏 _CRT_NON_CONFORMING_SWPRINTFS
    要么换 swprintf_s 函数
      

  7.   

    谢了 这个问题解决了
    又出了问题
    TCHAR str[100];
    TextOut(hdc,0,20*i,str,strlen(str));
    错误是
    “strlen”: 不能将参数 1 从“TCHAR [100]”转换为“const char *”
    这个怎么办