Hello everyone,
I am trying to remove a duplicate entry. My problem is in the two if statements following the for loop and I for some reason cannot figure it out. I have one entry in a file that has the same department name AND course number. I am trying to get one of those removed as my instructions are to list only distinct dept/course number. My question is can someone show me what my error is and how I might go about fixing it?
Code:
#include "classes.h"
int main(void)
{
int switchInput;
int i = 0;
int tempCourse = 0, tempCourse1 = 0;
char caseOneInput[5];
FILE *filePointer;
sched_record data[MAX_RECORD];
filePointer = fopen (BINFILE, "rb");
if (filePointer == NULL) {
printf("**Can't open file**");
printf("**Check file permissions of file path**\n");
exit(1);
}
printf("Enter your choice: ");
scanf("%d", &switchInput);
switch(switchInput)
{
case 1:
fread(data, sizeof(sched_record), MAX_RECORD, filePointer);
fclose(filePointer);
printf("Enter Dept Name: ");
scanf("%s", caseOneInput);
qsort(data, MAX_RECORD, sizeof(sched_record), sortFunction);
for (i=0; i<MAX_RECORD; i++){
if (!strcmp(caseOneInput, data[i].Dept)){
if(tempCourse != data[i].course);{
printf("\n%s %d", data[i].Dept, data[i].course);
tempCourse = data[i].course;
}
}
}
}
return 0;
}