struct global{
char lines[10][50];
int nlines;
float characters[90][2];
float linew;
string msgs;
void defaults(int);
global(){
msgs="";
characters[32][1]=999;
//defaults();
}
}g;
//...
int restore(){
defName(name);
fstream read(name, ios::in);
if(!read){
cout<<"Error: "<<name<<" not found.\nFollow setup process to repair.";
return 1;
}
g.linew=goTo(1);
g.nlines=goTo(2);
for(int i=33;i<=90;i++){
if(i=='#')g.characters['#'][1]=goTo('^', 0, 4); //Get correct # line
else g.characters[char(i)][1]=goTo(char(i));
}
read.close();
return 0;
}
int f2p(){
defName(name2);
fstream read(name2, ios::in);
if(!read){
cout<<"Error: "<<name2<<" not found.\nFollow setup process to repair.";
return 1;
}
for(int i=32;i<=90;i++){
if(i=='#')g.characters['#'][1]=goTo('^'); //Get correct # line
else g.characters[char(i)][0]=goTo(char(i));
}
read.close();
return 0;
}
Now the weird part is when I run f2p(). This line: else g.characters[char(i)][0]=goTo(char(i));
for some reason assigns the last value it gets to g.linew. So if it retrieves the numbers
4
5
22.5
564
8
For some very strange reason g.linew is given the value 8.
Then it gets even more perplexing. When I rearange the struct from
you are writing beyond the bounds of the array for(int i=32;i<=90;i++)
the <= should be a < since the array has 90 elements and indexes "[x]" are 0 based not 1 based like the size