我目前使用std::ofstream
如下:寫作stringstream的內容到ofstream的
std::ofstream outFile;
outFile.open(output_file);
然後我嘗試將std::stringstream
對象傳遞給outFile
如下:
GetHolesResults(..., std::ofstream &outFile){
float x = 1234;
std::stringstream ss;
ss << x << std::endl;
outFile << ss;
}
現在我outFile
只含有垃圾:「0012E708」全部重複。
在GetHolesResults
我可以寫
outFile << "Foo" << std:endl;
,它會輸出正確outFile
。
任何有關我在做什麼錯誤的建議?
我建議你改一下標題的東西在的行:「書面方式stringstream的內容到ofstream的」(或ostream的什麼事項) – 2008-11-27 22:09:22
埃裏克,你應該紀念約翰的回答所接受,這樣我可以刪除我的(這顯然比他的方法更糟糕) – 2013-07-19 16:30:07
好的,完成了。但是在那些日子裏,我使用了你的解決方案=) – Eric 2013-07-19 16:32:46