//this code is meant to copy all but the first 2 lines of a text file
//and paste it at the end of another text file
//the text file that is being copied from is of the following format:
//first line is comments
//second line is one number
//the remaining lines constitute a matrix of numbers (1,000 rows X 10,000 columns)
//the matrix is what must be copied and pasted into the other text file
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
string IN=argv[1], OUT=argv[2], temp;
//char temp[256];
ifstream instream;
ofstream outstream;
instream.open(IN.c_str(),ifstream::in);
outstream.open(OUT.c_str(),ofstream::app);
if (instream.fail()) cout << "Could not open instream." << endl;
if (outstream.fail()) cout << "Could not open outstream." << endl;
/*instream.getline(temp, 1, '\n');
//get past the comments
while ((temp='#'))
{
instream.ignore(1024, '\n');
getline(instream, temp, 1);
}
//get past the dimmensionality label
instream.ignore(1024, '\n');
*/
instream.ignore(1024, '\n');
instream.ignore(1024, '\n');
instream.ignore(2097152, '\n');
for (int c=0; c<1000; c++)
{
for (int i=0; i<10009; i++)
{
//instream.getline(temp, 256, ' ');
getline(instream, temp, ' ');
outstream << temp << " ";
}
outstream << endl;
}
instream.close();
outstream.close();
return 0;
}