Error in Visual Studio

Guys,
Please help me to get through this error.
https://imgur.com/a/tsN5DHf
Thanks in advance

It's impossible to know what's wrong without seeing your code. Please post reply with your code - preferably all of it so we can compile the program. Be sure to use code tags: that means after you paste the code into your post, highlight the code and click the <> button to the right of the edit window. This will cause the code to display when line numbers and syntax highlighting once it's posted.
You see that red "x" at the end of a source line?

Well that's the line that caused your exception.

So perhaps let the debugger show you the value of that Ny variable.
The whole code is quite big to paste it here to make it understandable, however the respected line is here


 
Q[i] = (B[Ny*i + j] - aP_u[Ny*i + j][Ny*i + j + 1] * u_star[i][j + 1] - aP_u[Ny*i + j][Ny*i + j - Ny] * Q[i - 1])/ (aP_u[Ny*i + j][Ny*i + j] + aP_u[Ny*i + j][Ny*i + j - Ny] * P[i - 1]);
Well each one of those array references is a potential source of the problem.

So go through each one and check
a) whether it is allocated
b) how much is allocated
c) that the index you're using to subscript it is in range.

Oh, and you can format these long lines for readability you know.
1
2
3
4
5
Q[i] = (B[Ny*i + j] - 
        aP_u[Ny*i + j][Ny*i + j + 1] * u_star[i][j + 1] - 
        aP_u[Ny*i + j][Ny*i + j - Ny] * Q[i - 1]) /
       (aP_u[Ny*i + j][Ny*i + j] + 
        aP_u[Ny*i + j][Ny*i + j - Ny] * P[i - 1]);


Factoring out Ny*i + j (which appears 9 times) might make things more readable as well.

Topic archived. No new replies allowed.