Hmmmm. Still get the ol' core dump. Troubling.
Also, my class hasn't covered dynamic array structure with malloc, so I'm betting it isn't expected.
That makes me think something is wrong in the loop structure.
Hmmmm. Still get the ol' core dump. Troubling.
Also, my class hasn't covered dynamic array structure with malloc, so I'm betting it isn't expected.
That makes me think something is wrong in the loop structure.
Did you fix the problem with the blank variable being uninitialized?
Since you've changed the program, we'd need to see the new version to make good suggestions.
No, I wouldn't recommend making your arrays dynamic. Adds complexity you don't need, right now.
This is wrong, I think. What if the value you read in is less than threshold? Then you are going to increment i, and try to do operations on the array value at index i before you actually read data into it.Code:while(fscanf(fp,"%f %f", &t[i], &b[i])!=EOF) { while (b[i] < threshold) { i++; }
Read your data into your array once, then process it.
Also, nothing you posted in that code is finding local maxima.
Illiad, if you post up a small (say 100 rows) data file, I'll be glad to run it through your program. I see problem with it though. Like here:
Will surely cause i to go out of range, many times. Add && i < 3601 or whatever the number of rows in the file is, or explicitly check for the end of the file.Code:while(b[i] < threshold) { i++; }
Seems like the inner loop should know what the outer loop was already given in logic - but no, it doesn't do that.
still won't be enough. Consider the very first iteration of the outer loop - the very first element of the arrays will have information in it, all the others will have whatever was in memory before (or does declaring arrays on the stack cause them to get zeroed out? Either way, it doesn;t matter).Will surely cause i to go out of range, many times. Add && i < 3601 or whatever the number of rows in the file is, or explicitly check for the end of the file.
If that one information piece is less than threshold, i gets incremented and the code then attempts to do operations on later array elements. Which don't have useful information in them. So even if i stays in bounds, the results will be garbage.
Whih is why I suggest that he read in all of his information once, using arrays declared with 3601 elements instead of 300000.