Hi, i want to write from one file to another. i managed to get the file to write but not in the way i expected it too, there is more to the program but for now i just need to know how can i mirror one file...
My input file contains:
peter 3 / + - *
Dahne 8 + - / *
but my outfile saves as:
peter
3
/
+
-
*
...... and so on
how do i fix this? i need it to look exactly like the input file for now
#include <fstream>
#include <cstdlib>
#include <iostream>
#include <string>
int main()
{
using namespace std;
ifstream in_stream;
ofstream out_stream;
in_stream.open("precedence.dat");
if(in_stream.fail( ))
{
cout << "input file opening faild.\n";
exit(1);
}
out_stream.open("results.dat");
if (in_stream.fail( ))
{
cout << "output file opening failed.\n";
exit(1);
}
//char line;
string next;
//in_stream.get(next);
while(! in_stream.eof())
{
in_stream>>next;
out_stream<< next<< endl;
//in_stream.get(next);
}
in_stream.close( );
out_stream.close( );
return 0;
}