stl string TRACE问题

来源:互联网 发布:封面设计用什么软件 编辑:程序博客网 时间:2024/06/05 06:24

程序用要输出调试信息,但使用TRACE总是提示:"CrtDbgReport: String too long or IO Error"

 

TRACE(_T("head: %s/n"), str.c_str());  //str是一个wstring类型

 

网上找了一下,可行的办法是:

 char* old_locale = _strdup( setlocale(LC_CTYPE,NULL) );

    setlocale( LC_CTYPE, "chs" );

    TRACE(_T("head: %s/n"), str.c_str());

    setlocale( LC_CTYPE, old_locale);

    free(old_locale);

原创粉丝点击