I can't figure out why the output is going through twice.
int lines = 3
myReadFile.open("graph.txt");
if (myReadFile.is_open()) {
//Read in each value one at a time
while (!myReadFile.eof()) {
for(int i = 0; i < lines; i++) {
for(int j = 0; j<lines; j++) {
myReadFile >> output;
output2 = atoi(output);
Graph[i][j] = output2;
cout << "Graph[" << i <<"][" << j <<"] = " << output2 << endl;
}
//cout << output << output2 << endl;
}
}
} else {
cout << "graph.txt does not exist." << endl;
}
myReadFile.close();
output is below:
Graph[0][0] = 0
Graph[0][1] = 65
Graph[0][2] = 4
Graph[1][0] = 7
Graph[1][1] = 0
Graph[1][2] = 68
Graph[2][0] = 67
Graph[2][1] = 84
Graph[2][2] = 0
Graph[0][0] = 0
Graph[0][1] = 0
Graph[0][2] = 0
Graph[1][0] = 0
Graph[1][1] = 0
Graph[1][2] = 0
Graph[2][0] = 0
Graph[2][1] = 0
Graph[2][2] = 0
It does what I need it to, but it goes back though and zeros them out. Any help would be great! Thanks!