reading from a file

I need to a 7x7 matrix read from a file , but it isn't working.. Any idea why?



bool LoadGame()
{

ifstream myfile("file".txt");
if (myfile.is_open())
{
while (!myfile.eof()){
for (int i = 0; i <= 7; i++)
for (int j = 0; j <= 7; j++)
myfile >> matrix[i][j];
}
}
myfile.close();
else cout << "Unable to open file";


}

file".txt" ← stray " in the middle

your loop is not correct: now it will overwrite your matrix until it mess it all up.
Array indices start at 0. So a 7x7 matrix has indexes from 0 to 6. You're going from 0 to 7. So you want:
1
2
for (int i = 0; i < 7; i++)
for (int j = 0; j < 7; j++)
Topic archived. No new replies allowed.