This is my code:
#include <iostream> #include <fstream> using namespace std; int main() { ifstream ifile ("input.dat", ios::in); ofstream ofile ("output.dat",ios::out); int num; ifile >> num; ofile << num; ofile << endl; ofile << "Did we go to new line?"; ofile << endl; return 0; }
The problem is that everything in output.dat is on the same line. How can i solve this?
Thanks!
EDIT: I used Windows to view files and Linux to compile. That is why I came across this problem. Using cat output.dat
on the Linux side to view the contents of the file would indicate that line breaks in Windows and Linux were different at the time.
source share