Hey all, I am trying to first write an array to a text text file, delete the array, then later in the program I need to use the array again so I need to open the text file and read the array and call it the same name as before. What I have so far is:
// to write array "truck_data2" to text file
fstream myfile;
myfile.open ("truck_data2.txt");
for(int i=0;i<=21;i++)
{
myfile<<truck_data2[i]<<endl;
}
myfile.close();
delete[] truck_data2;
// and then later in program to read array from text file andname the array "truck_data2"
ifstream myfile;
myfile.open("truck_data2.txt");
while (! myfile.eof() )
{
getline (myfile,truck_data2);
}
myfile.close();
I think the writing the array to text file is ok but reading the array is wrong. Thanks in advence for any help.
Colm.