Hello fellow C++ coders, I have some code that builds but during debugging with local windows debugger (going down line by line) I get this error that aborts the program:
Exception thrown at 0x01394FDA in MonteCarloDemo.exe: 0xC0000005: Access violation reading location 0xCCD6AACC.
If there is a handler for this exception, the program may be safely continued.
I check the hexadecimal value and I have traced it to this function:
1 2 3 4 5 6 7 8 9 10 11
double Mie::GetCext(double lambda) {
int l;
l = int(floor((lambda - LambdaMin) / LambdaDiff));
if (l<0) {
l = 0;
}
if (l >= LambdaNum) {
l = LambdaNum - 1;
}
return MD[l].Cext;
}
Some explanation of the variables: This function is a member of the class Mie as you can see. It is meant to return an extinction cross section for light. Here are some of the associated other functions in the Mie class and the calls to the functions in int main();
@Thomas1965 or anyone else seeing the question, the value of int l was 20 so it should be MD[20].Cext; for the wavelength range of 650.0 and 1350.0 but how does that help solve the problem? The exception gets thrown at MD[l].Cext when I step into the function not at int l and not at l = int(floor((lambda - LambdaMin) / LambdaDiff));