【发布时间】:2011-06-15 02:15:20
【问题描述】:
我正在尝试在 ofstream 中创建一个新行,但它不起作用。 OUTPUT.txt 中的所有内容都写在同一行
std::ofstream output;
output.open("OUTPUT.TXT");
output << "sometext" << "\r\n" << "sometext" << "\r\n" << "sometext";
output.close();
我也试过
output << "sometext" << std::endl << "sometext" << std::endl << "sometext";
和
output << "sometext" << "\n" << "sometext" << "\n" << "sometext";
和
output << "sometext" << '\n' << "sometext" << '\n' << "sometext";
所有内容都写在同一行,没有新行...我错过了什么吗?
【问题讨论】:
-
在 Windows 7 上,使用 notepad.exe 读取输出文件