Reputation: 27
I am a novice programmer, so please deal with me. I'm writing a program to analyze data. When I execute the program, I receive a "floating point exception" and I have no clue why. Here is the section of code where the error is originating from. From what I can tell, the if
statement seems to be the problem but I do not understand why. Any help you can give is greatly appreciated!
double tArray[600][49];
void main() {
double finalArray[600][0]
double n = 0;
int h = 0;
try {
for (int i = 0; i < 600; j++) {
for (int j = 1; j < 16; j++) {
h++;
n = tArray[i][j * 3 - 1] - tArray[i][j * 3 - 2];
double t = -30;
if (n < t) {
finalArray[i][0] = tArray[h][3 * j] - tArray[h + t][3 * j];
h++;
}
}
}
}
}
Upvotes: 2
Views: 361
Reputation: 48320
Declaring double finalArray[600][0]
means the array is 600 elements by 0 elements. I think you want the second dimension to be 1. Remember, you need to declare the number of rows and columns, but indices start at 0.
Upvotes: 1
Reputation: 124
Try declaring finalArray as:
double finalArray[600][1];
It appears that the original declaration did not allocate any space for the elements.
If not try allocating only a single dimensional array like this:
double finalArray[600];
Hope this helps!
Upvotes: 1