zoukankan      html  css  js  c++  java
  • _CrtDbgReport: String too long or IO Error

    _CrtDbgReport: String too long or IO Error

     

    wprintf_s不能正常出中文的解决

    使用如下方法wprintf_s出中文往往出现带?的乱:

    wprintf_s(L"%s",(LPCWSTR)cmdLineArr[1]);

     解决方案:包含文件locale.h,并在程序开始setlocale(LC_ALL, "chs");

    这样wprintf_s便能正常打印出中文字符串了:

     //指定当前程序的编码为简体中文,这样才能用wprintf正确出中文

    #include <locale.h>
    setlocale(LC_ALL, "chs");

    样对TRACE(_T("第一个:%s,第二个:%s"),str1,str2);,如果运行出信息:“_CrtDbgReport: String too long or IO Error”。亦可用上述方法解决。

     

    TRACE在定义时就已考unicode,所以不需要加_T

    可以采用OutputDebugString()来代替TRACE,它自采用UNICODE和非UNICODE

     

    Microsoft Visual Studio Feedback上的反馈

    http://connect.microsoft.com/VisualStudio/feedback/details/425215/bug-with-trace-and-crtdbgreport

    There is a bug with TRACE and _CrtDbgReport when working with the wide string.
    _CrtDbgReport can't handle the wide string correctly when the wide string contains non-ascii characters.

    貌似在Beta 2 of Visual Studio 2010.修正了该bug

  • 相关阅读:
    leetcode--95. Unique Binary Search Trees II
    leetcode--96. Unique Binary Search Trees
    leetcode分类总结
    leetcode-115. Distinct Subsequences
    tcpdump安装配置及抓包分析
    dp经典案例
    tree的各种问题
    大数的阶乘算法
    由mmap引发的SIGBUS
    win10系统下如何查看端口被哪个进程占用
  • 原文地址:https://www.cnblogs.com/BeyondTechnology/p/1931533.html
Copyright © 2011-2022 走看看