do
{
ReadFile = fopen("StudentDetails.txt", "r");
if(!ReadFile)
{
system("cls");
printf("\n");
printf("\t\t ***************************************\n");
printf("\t\t ***************************************\n");
printf("\t\t *** ***\n");
printf("\t\t *** WELCOME TO ***\n");
printf("\t\t *** CLASS ATTENDANCE SYSTEM ***\n");
printf("\t\t *** ***\n");
printf("\t\t ***************************************\n");
printf("\t\t ***************************************\n");
printf("\n\n");
printf("\t\t This File Cannot Be Open Successfully!!\n");
printf("\t\t Please Check It!!\n");
exit(-1);
}
++temp_week;
system("cls");
printf("\n");
printf("\t\t ***************************************\n");
printf("\t\t ***************************************\n");
printf("\t\t *** ***\n");
printf("\t\t *** WELCOME TO ***\n");
printf("\t\t *** CLASS ATTENDANCE SYSTEM ***\n");
printf("\t\t *** ***\n");
printf("\t\t ***************************************\n");
printf("\t\t ***************************************\n");
printf("\n\n");
printf("\t\t ******** MARKING OF ATTENDANCE ********\n");
printf("\t\t PRESENT = 1 ABSENT = 0\n\n");
for(i=0; fscanf(ReadFile,"%d|", &Student[i].studNo) != EOF; i++)
{
fscanf(ReadFile, "%d", &Student[i].regNo.year);
fscanf(ReadFile, "%c", &Student[i].regNo.campus);
fscanf(ReadFile, "%c", &Student[i].regNo.school);
fscanf(ReadFile, "%c", &Student[i].regNo.level);
fscanf(ReadFile, "%d|", &Student[i].regNo.serial_number);
fscanf(ReadFile, "%[^|]|", &Student[i].student_Surname);
fscanf(ReadFile, "%[^|]|", &Student[i].student_givenName);
fscanf(ReadFile, "%[^|]|", &Student[i].gender);
fscanf(ReadFile, "%[^|]|", &Student[i].father_name);
fscanf(ReadFile, "%[^|]|", &Student[i].address1);
fscanf(ReadFile, "%[^|]|", &Student[i].address2);
fscanf(ReadFile, "%s", &Student[i].address3);
printf("\t\t %d ", Student[i].studNo);
printf("%d", Student[i].regNo.year);
printf("%c", Student[i].regNo.campus);
printf("%c", Student[i].regNo.school);
printf("%c", Student[i].regNo.level);
printf("%d ", Student[i].regNo.serial_number);
printf("%c ", Student[i].gender);
printf("%-10s ", Student[i].student_Surname);
printf("%-10s ", Student[i].student_givenName);
printf(": ");
scanf("%d", &temp_Att);
while(temp_Att != 1 && temp_Att != 0)
{
printf("\n\t\t You Have Enter Out of Range\n");
printf("\t\t Please Re-enter Again\n");
printf("\t\t\t\t\t\t\t: ");
scanf("%d", &temp_Att);
}
[B] fprintf(AppendingFile, "%d ", temp_Att);
}
fprintf(AppendingFile, "\n");[/B]
printf("\n");
printf("\n\t Do You Want To Continue Mark Attendance(0 to Stop; 1 to Access)? ");
scanf("%d", &temp_markatt);
printf("\n\n");
fclose(ReadFile);
}while(temp_markatt != 0);
the problem is after i assign the value into my text file,
i'll get incorrect result, which i have a space before the '\n' when end of the line.
but i want is when end of the line is '\n'
example,
1 0 1 0 1<space>'\n' ---- Incorrect
1 0 1 0 1'\n' ----- Correct