Hey guys,
thought I would get back to the forum to show the solutions that I came up with in case other people have similar problems. The problem that I was having with the empty file was because I was not actually testing for the empty file before I processed it so i added this code
Code:
if (fscanf(inputStream,"%s", storeEOF) == EOF) {
exit(2);
}
and another problem that I discovered it that DJGPP would compile but not run the program due to memory problems. This was because my bubble sort algorithm was not quite correct. originally I had this:
Code:
/ bubble sort algorithm
for (i=0; i < ARRAY_LENGTH; i++) {
for (j=0; j < ARRAY_LENGTH; j++) {
if (((events[j].date.month) > (events[j+1].date.month)) ||
((events[j].date.month) == (events[j+1].date.month)) &&
((events[j].date.day) > (events[j+1].date.day))) {
tempEvent = events[j];
events[j] = events[j+1];
events[j+1] = tempEvent;
} // end of if
} //end of inner j for loop
} // end of outer i loop
So i changed it to this
Code:
for (i=0; i < numEvents-1; i++) {
for (j=0; j < numEvents-1; j++) {
if (((events[j].date.month) > (events[j+1].date.month)) ||
((events[j].date.month) == (events[j+1].date.month)) &&
((events[j].date.day) > (events[j+1].date.day))) {
tempEvent = events[j];
events[j] = events[j+1];
events[j+1] = tempEvent;
} // end of if
} //end of inner j for loop
} // end of outer i for loop
it seemed that the bubble sort was running off the end of the array. I had declared and array of ARRAY_SIZE and was looping through this array instead I should have been looping through ARRAY_SIZE-1