【发布时间】:2019-09-21 08:35:46
【问题描述】:
使用 g++ 编译后,下面的程序仅打印 std::wcout 表达式。但是如果你取消注释第 8 行,它会正确打印三个表达式。
我想知道这种奇怪行为的原因。
#include <iostream>
#include <cstring>
#include <boost/format.hpp>
int main () {
int x = 10;
wchar_t str[] = L"Hello, world!";
// std::cout << "what?" << std::endl;
std::wcout << L"str = \"" << str << L"\" | len = " << wcslen(str) << L"\n";
std::cout << boost::format("x = %d | &x = %p") % x % &x << std::endl;
return 0;
}
【问题讨论】:
-
好的,谢谢你的链接!