[Solved] Thread 1: EXC_BAD_ACCESS (code=1, adress=0x0)


I believe your error is in your input file: you read i and j and use it to access your arrays, without verifying that these value are within expected boundaries.

For instance, if you improve your questioned code with an error message, like:

for (k=0; k<M; k++){
    input>>i>>j>>V;
    if (i>=N || j>=N) {
        cerr << "Bad Input for k="<<k<<": "<<i<<","<<j<<","<<V<<endl;
        continue;
    }
    //assert(i<N && j<N);  variant if you don't care for the values
    Graf[i][j] = V;
}

You’ll get the following results:

Bad Input for k=3: 7,0,6
Bad Input for k=4: 5,0,0
Bad Input for k=5: 9,1,15
Bad Input for k=6: 2,7,9

0

solved Thread 1: EXC_BAD_ACCESS (code=1, adress=0x0)