Assertion failure
Apr 26, 2014 at 11:17pm UTC
Hey guys. I'm trying to load into a 2d array from a text file of integers. The array loads fine, but after loading and printing the 2d array I get an assertion failure. Ideas?
Here is the load:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
ifstream myfile;
string fileName;//name of file
cout<<"Please enter file name: " ;
cin >> fileName;
myfile.open(fileName.c_str(), ios::in);
int size;
//load files if files exist
if (myfile.good()){
cout<<"successful" <<endl;
myfile >> size;
Graph e = Graph(size);
while (!myfile.eof()){
for (int row = 0; row < size; row++){
for (int col = 0; col < size; col++){
myfile >> e.a[row][col];//fills array
/*if(e.a[row][col] == 0){
e.edge[row][col] = false;
}else{
e.edge[row][col] = true;
}*/
cout << e.a[row][col];
}
cout << endl;
}
}
Apr 27, 2014 at 9:09pm UTC
Anyone? Help?
Apr 27, 2014 at 10:29pm UTC
Topic archived. No new replies allowed.