When I run a program using the read part of fstream, I get this return value:
-1073741819
the actual function is part of a corrupt for loop, which I will try to explain:
for(int i = 0; i < vrs_top_i * 3; i += 3)
{
int X1x = FileRead(file2, i + 1);
int X1y = FileRead(file2, i + 2);
char X1sym = FileRead(file2, i + 3);
viral_data.add(new X1(X1x, X1y, X1sym));
}
vrs_top_i is a variable declared like this: int vrs_top_i = FileRead(file2, 0);
add is a function for a custom list I made, essentially the same as push_back()
for vectors. X1 is a class I made with a constructor that takes three arguments, two ints and a char.
Now for the corrupt part of the loop:
now, when I put "exit(0);" under the third line of the loop "char X1sym...+ 3);" (or anywhere else in the loop, for that matter) It does what you expect: ends the program with a return value of zero.
but when I put "if(i == 0)exit(0);", or "if(i == 3)", I get the aforementioned return value.
So I'm guessing that means that i is never 0 or 3.
So does anybody know what the return value means?
NB: FileRead is declared like so:
int FileRead(std::fstream& file, int pos)
{
int data;
file.seekg(file.beg + pos * sizeof(int));
file.read(reinterpret_cast<char*>(&data), sizeof(data));
return data;
}