For this assignment, I'm snagged on what to do next. I'm supposed to be moving contents of one file (containing about 100 random numbers and spaces) to an outfile--completely intact--except for removing any extra spaces. I can do the latter, just can't get the entire contents of the file to move to the outfile for editing. This is just the necessary parts of the program.
#include <iostream>
#include <fstream>
#include <cstdlib>
usingnamespace std;
int main()
{
ifstream in_stream;
ofstream out_stream;
in_stream.open("infile.cpp");
if (in_stream.fail())
{
cout << "Input file opening failed." << endl;
exit (1);
}
out_stream.open("outfile.cpp");
if (out_stream.fail())
{
cout << "Output file opening failed." << endl;
exit(1);
}
/**Right here is the problem. I tried char array_infile [100].**/
int ?? /*declarations?, initializations?*/
in_stream >> /*from infile?*/
/*This appears in the outfile above the edited version of infile*/
out_stream << "This is the edited version of infile.cpp. All spaces of more than" << endl;
out_stream << "two have been removed. You should see a series of numbers with only" << endl;
out_stream << "one space between each number here: "
in_stream.close();
out_stream.close();
return 0;
}
I think I finally found a section in the book to help me. It appears I have this set up wrong overall. (?) I'll give that a go and see what the changes reveal