C++ ofstream line break

后端 未结 2 515
终归单人心
终归单人心 2021-01-12 03:53

This is my code:

#include 
#include 
using namespace std;
int main()
{
    ifstream ifile (\"input.dat\", ios::in);
    ofstre         


        
相关标签:
2条回答
  • 2021-01-12 04:21

    std::endl already inserts a linebreak, so you have linebreaks in your file. I assume you are generating your file on a LF system (Linux or other UNIX-like) and viewing it on a CRLF system. In this case, your linebreak won't show in the text editor as a linebreak. unix2dos is your friend.

    0 讨论(0)
  • 2021-01-12 04:35

    Replace std::endl with "\r\n" to get CRLF instead of just LF.

    0 讨论(0)
提交回复
热议问题