thanks for helping me
can someone help me with this code?
Code:
void files(ptrcourse *pFirst, ptrstudent *pHead, int ctr[])
{
FILE *pFile;
ptrcourse pCurrent,pTemp,pNew;
ptrstudent sCurrent,sTemp;
string30 temp;
pNew = malloc(sizeof(struct course));
pNew = *pFirst;
pFile = fopen("MP.txt", "rt");
if(pFile == NULL)
{
pFile = fopen("MP.txt", "wt");
}
else
{
while(!EOF)
{
pCurrent = pNew;
fgets(temp, sizeof(struct course), pFile);
strcpy(pTemp->coursecode,strtok(temp,"\t"));
strcpy(pTemp->coursecode,strtok(NULL,"\t"));
pTemp->section = atoi(strtok(temp, "\t"));
pTemp->section = atoi(strtok(NULL, "\t"));
pTemp->units = atoi(strtok(temp, "\t"));
pTemp->units = atoi(strtok(NULL, "\t"));
strcpy(pTemp->schedule,strtok(temp,"\t"));
strcpy(pTemp->schedule,strtok(NULL,"\t"));
pTemp->ptrtime.shr = atoi(strtok(temp, "\t"));
pTemp->ptrtime.shr = atoi(strtok(NULL, "\t"));
pTemp->ptrtime.smin = atoi(strtok(temp, "\t"));
pTemp->ptrtime.smin = atoi(strtok(NULL, "\t"));
pTemp->ptrtime.ehr = atoi(strtok(temp, "\t"));
pTemp->ptrtime.ehr = atoi(strtok(NULL, "\t"));
pTemp->ptrtime.emin = atoi(strtok(temp, "\t"));
pTemp->ptrtime.emin = atoi(strtok(NULL, "\t"));
strcpy(pTemp->lecturer,strtok(temp,"\t"));
strcpy(pTemp->lecturer,strtok(NULL,"\t"));
pTemp->slots =atoi(strtok(temp, "\t"));
pTemp->slots =atoi(strtok(NULL, "\t"));
pTemp->pNext = NULL;
pCurrent = pNew;
pCurrent = pCurrent->pNext;
};
}
}
The format of the output text file should be as follows:
<Course_code_1><space><section1><new line constant \n>
<MW or TH><space><HHMM-HHMM schedule 24-hour format><space><lecturer><new line constant \n>
<total slots><space>{<ID_number1>,<ID_number2>,
}<new line constant \n>
<Course_code_2><space><section2><new line constant \n>
<MW or TH><space><HHMM-HHMM schedule><space><lecturer><new line constant \n>
<total slots><space>{<ID_number1>,<ID_number2>,
}<new line constant \n>
. . .
. . .
. . .
<Student_ID_1><space><name_1><space><age1><space>< year level1><new line constant \n>
<course_code_1>_<section1><space><course_code2>_<s ection2>
<course_code>_<section><new line constant \n>
<Student_ID_2><space><name_2><space><age2><space>< year level2><new line constant \n>
<course_code_1>_<section1><space><course_code2>_<s ection2>
<course_code>_<section><new line constant \n>
. . .
. . .
. . .