Thanks tabstop. What function should I use? So far this is what I have...it's a loop that calculates something (in this case that something is "value"), then that something is what I am trying to add into a new column into the text file. I figured I had to do it in the loop. I'm not sure how creating a copy of the file would work because I don't think I can use my calculated values outside of my while loop.
Code:
//while loop to extract data from .txt file
while(getline(datain, line1))
{
istringstream datstream(line1, istringstream::in);
datstream >> dum1[0] >> dum1[1] /*>> dum1[2] >>*/;
datastore[i][0] = strtod(dum1[0].c_str(), &pEnd); //lat
datastore[i][1] = strtod(dum1[1].c_str(), &pEnd); //long
latpix[i] = (laurentides.lat-datastore[i][0])/(laurentides.x_pixsize);
lonpix[i] = (datastore[i][1]- laurentides.lon)/(laurentides.y_pixsize );
cout << "Lat : " << datastore[i][0] <<" Lon: " << datastore[i][1] << " " << "pixel lat: " << latpix[i] << "\t" << "pixel lon: " << lonpix[i] << endl;
//offset here calculates the number of pixels that the data occupies in the actual binary file and points to it
offset = latpix[i]*laurentides.numsamples+lonpix[i];
//here were getting the size of the data in memory
offset = offset*sizeof(float);
cout<<"reading file at "<< offset <<endl;
is.seekg (offset, ios::beg);
is.read ((char *) &value[i], sizeof(double));
cout <<"THIS IS FSEEK VALUE: " << value[i] << endl;
ostringstream value_streaming;
/* ----Code I was playing with to append data to my text file but not working at all ---
value_streaming << value[i];
string_value = value_streaming.str();
fstream testing;
testing.open(argv[2], fstream::in | fstream ::out|fstream::app);
testing << string_value << endl;
//string_value = value_streaming.str();
//value[i] >> dum1[6];
datstream >> dum1[2] >> dum1[3] >> dum1[4] >> dum1[5] >> dum1[6];
testing.close();
*/
if( i == 4)
break;
i++;
}