デバッグ出力をC++ 03プロジェクトに追加しようとしましたが、奇妙な結果がありました。 、いくつかの理由名前のないstd :: ofstreamへの文字列の出力が、なぜ私に16進数を与えるのですか?
#include <fstream>
int main()
{
{
std::ofstream file("/tmp/test.txt");
file << "hello" << " ... OK, this works\n";
}
std::ofstream("/tmp/test.txt",std::ios_base::app) << "hello"
<< " ... no, I mean hello!\n";
}
ここで私は、コンパイル後に何を得るのです:ここでは単純化されたテストコードだ
$ g++ test.cpp -o test && ./test && cat /tmp/test.txt
hello ... OK, this works
0x80487fe ... no, I mean hello!
なぜ私は無名のstd::ofstream
オブジェクトに文字列を出力する場合には進数を得るのですか?そして、なぜ2番目の文字列の後続出力が機能するのですか?
可能な重複:[std :: ostringstreamは、その内容の代わりにc-stringのアドレスを出力します。](https://stackoverflow.com/questions/8287188/stdostringstream-printing-the-address-of-the-c -string-of-its-content) – NathanOliver