I asked out of genuine curiosity. I have a background in electrocardiography (not programming), so I am moderately interested in the subject. I wouldn't have thought that biomedical programming would be an intro course...I would have figured it would have prereqs up to and including algorithms and data structures.
Anyway, here's your code. You really should post the code in your post rather than as an attachment.
Code:
/* Instantaneous Heart Rate Analysis
Date: 11.15.10
This program calculates the instantaneous heart rate at each heart beat.
*/
#include <stdio.h>
#include <string.h>
FILE *fp;
char fn[100000];
int main(int argc, char *argv[]) {
float t1, IHR;
int i, n, blank, threshold;
float t[300000];
float b[300000];
n = 3601;
strcpy(fn,argv[1]);
fp = fopen(fn,"r");
if(fp==NULL) {
printf("Error: File Does Not Exist\n");
}
else {
printf("File Opened Successfully\n");
i = 0;
threshold = 100;
t1 = -1;
while(fscanf(fp,"%f %f", &t[i], &b[i])!=EOF) {
while (b[i] < threshold) {
i++;
}
IHR = 60. / (t[i] - t1);
if ( t1 > -1) {
printf("The instantaneous heart rate is %f",IHR);
}
t1 = t[i];
i = i + blank;
}
fclose(fp);
}
return 0;
}
Now, here:
blank is an uninitialized value. You have no idea what it contains, so it could very well making i some crazy number that exceeds the bounds of your array.
Depending on your environment, the declaration of two 300000-element arrays of floats may also be blowing the stack.
Without the data it's hard to say much more than that.