We have a project for our CS class thats purpose is to read 3 different files, compare them, and list exam scores and user names in a new file
The files are to be as follows:
class.txt - This is the roster of the course. The first column is the identification number of the student followed by the name of the student.
webCT.txt - This is the file with the necessary information to upload scores to WebCT. The first column is the identification number of the student and the second is the university ITaP login.
exam.txt - This file contains the student identification number and the score earned on the exam.
uploadExam.txt - The file you will create, this file will have the the score and university ITaP login for each student separated by a comma and a space (this is known as a comma delimited file). If a student in the class.txt file does not have a score in exam.txt then the university ITaP login and a score of zero should be listed in this file.
badID.txt - In this file you will place all records in exam.txt that DO NOT have a matching student identification number in the class.txt file. Data placed in this file are a result of an incorrectly coded student identification number.
The files are also formatted as follows:
12345 Jackson, Keith
11111 Gibson, Robert G
22222 Sanders, Ryan
33333 Anderson, Jennifer A
44444 Martinez, Mary
11111 75 Gibson, Bob G
22222 88 Sanders, R
33333 90 Anderson, Jenny
12344 77 Jackson, Keith
Exam1Score, User Id
12344 77 Jackson, Keith
so far we have gotten our program to load the first two files, but we are stuck on how to load the exam.txt file. We can only use strings for this project and it will eventually need to be able to accept any number of inputs. Here is our code:
Currently we are recieving a segmentation fault when we run the program for the exam.txt file. Any help that anyone could give us pertaining to this problem, or any other help in writing this code would be great.
int main ()
fpClass = fopen("class.txt", "r");
for(counter=1; counter <= 5; counter++)
fscanf(fpClass, "%d%d%d%d%d", &id1);
id2[counter] = id1;
fgets(character, 35, fpClass);
// printf("%s\n", character);
names[counter] = character;
fpwebCT = fopen("webCT.txt", "r");
for(counter2 = 1; counter2 <= 5; counter2++)
fscanf(fpwebCT, "%d%d%d%d%d", &id3);
id4[counter2] = id3;
fgets(login, 35, fpwebCT);
names2[counter2] = login;
for (counter3=1; counter3 <=5; counter3++)
if (id4[counter2] == id2[counter3])
fpexam = fopen("exam.txt", "r");
counter2 = 0;
for(i = 1; i <= 4; i++)
fscanf(fpexam, "%d%d%d%d%d", &id5);
id6[i] = id5;
fscanf(fpexam, "%d%d", &score);
//scores[i] = score;
for (counter2=1; counter2 <=5; counter2++)
if (id4[i] == id6[counter2])