Trying to save an array of variables to load at a later time, not working correctly..
Code:
bool savevars(int vars[28][14])
{
using std::ofstream;
int loop;
int loop1;
char *temp = new char;
ofstream filestr;
filestr.open ("data.dat");
if (filestr.is_open())
{
for (loop=1;loop<=28;loop++)
{
for (loop1=1;loop1<=14;loop1++)
{
wsprintf(temp,"%d",vars[loop][loop1]);
filestr <<temp<<'\n';
}
}
}
else
{
return false;
}
return true;
filestr.close();
}
bool loadvars()
{
using std::ifstream;
int j, k;
extern int sectionone[28][14];
ifstream filesstr;
filesstr.open("data.dat", ios::in);
if (filesstr.is_open())
{
for (j=1;j<=28;j++)
{
for (k=1;k<=14;k++)
{
filesstr >> sectionone[j][k];
}
}
}
else
{
return false;
}
return true;
filesstr.close();
}
its saving correctly, the file changes in the correct ways every time it is saved, but the loading isnt working... Or is it the other way around?
Help??