c++ - 用 swprintf_s 格式化 double 并发送到 OutputDebugStringW

标签 c++ windows

我在调试窗口中格式化 double 打印输出时遇到问题。我尝试使用 swprintf_s 函数和 %d,该值是 0.804,但它根本不起作用。

enter image description here

我得到值 65384...我应该如何改进这段代码?

void MyOutputFunction(const wchar_t *format, double args)
{  
  wchar_t buf[2048];    
  swprintf_s(buf, _countof(buf), format, args);
  OutputDebugStringW(buf);
}

最佳答案

您应该使用 %f(不是 %d)作为 double< 的格式说明符s.

关于c++ - 用 swprintf_s 格式化 double 并发送到 OutputDebugStringW,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30437603/

相关文章:

c++ - 等到用户在 C++ 中按下 Enter 键?

c++ - "cannot instantiate abstract class"多重继承和第三方接口(interface)

c++ - 用 C 字符串初始化 std::string 的奇怪方法

c++ - 混合调试和发布库 : Windows vs Linux, 静态与共享

c++ - 从其他窗口(Qt)释放窗口?

python - os.walk 无法正确处理路径中的 unicode 字符

c++ - std::make_unique SFINAE 友好吗?

android - [Cocos2dx]如何为自定义 Sprite 设置图片?

windows - vim 设置标签为绝对路径

c# - 定期从网络共享文件夹中读取文件的最有效方法是什么?