gahhon 13 Junior Poster

there have problems with the output and the calculation...

void Mark_Attendance()
{
	int answer, temp_Att;

	FILE *ExistingFile, *AppendingFile, *ReadFile;

	ExistingFile = fopen("Attendance.txt", "w+");
	AppendingFile = fopen("Attendance.txt", "a");
	ReadFile = fopen("StudentDetails.txt", "r");

	if(!ExistingFile || !AppendingFile || !ReadFile)
	{
		system("cls");
		printf("This File Cannot Be Open Successfully!!\n");
		printf("Please Check It!!\n");
		exit(-1);
	}
	else
	{
		system("cls");
		printf("How Many Weeks You Want To Add On? ");
		scanf("%d", &week);
		while(isalpha(week))
		{
			printf("You Have Enter Out of Range\n");
			printf("Please Re-enter Again\n");
			printf("How Many Weeks You Want To Add On? ");
			scanf("%d", &week);
		}

		week = week + 6;
		student = student + 5;

		fprintf(ExistingFile, "1 0 0 1 1\n");
		fprintf(ExistingFile, "1 1 1 1 1\n");
		fprintf(ExistingFile, "0 0 1 1 0\n");
		fprintf(ExistingFile, "1 0 0 1 1\n");
		fprintf(ExistingFile, "1 1 0 0 1\n");
		fprintf(ExistingFile, "1 0 1 0 1\n");

		system("cls");
		printf("\t\t   ********	MARKING OF ATTENDANCE ********\n");
		printf("\t\t                     PRESENT = 1  ABSENT = 0\n\n");

		for(x=6; x<week; x++)
		{
			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);
				}
				fprintf(AppendingFile, "%d ", temp_Att);
			}
			fprintf(AppendingFile, "\n");
			printf("\n\n");
		}

		printf("\t******** ATTENDANCE COMPLETED AND SAVED ... THANK YOU!! ********\n\n");
		system("pause");
		system("cls");

		for(x=0; x<week; x++)
			for(i=0; fscanf(ExistingFile,"%d ", &Attendance[x][i]) != EOF; i++)

		for(i=0; i<student; i++)
		{
			studPresence[i] = 0;	
			for(x=0; x<week; x++)
				studPresence[i] += Attendance[x][i];
		}

		for(x=0; x<week; x++)
		{
			weekPresence[x] = 0;
			for(i=0; i<student; i++)
				weekPresence[x] += Attendance[x][i];
		}

		while(answer != 4 || answer > 4)
		{
			printf("(1) To View The Student Attendance\n");
			printf("(2) To View The Week Attendance\n");
			printf("(3) To View 2-D Student Attendance\n"); 
			printf("(4) Back\n");
			printf("Please Type And Enter\n");
			scanf("%d", &answer);
			
			if(answer == 1)
				Report_on_Attendance_for_Each_Week();
			else if(answer == 2)
				Report_on_Attendance_for_Each_Student();
			else if(answer == 3)
				OutputFunction();
			else if(answer == 4)
				break;
			else
			{
				printf("You Have Enter Out of Range\n");
				printf("Please Re-enter Again\n");
			}
		}
	}
	fclose(ExistingFile);
	fclose(AppendingFile);
	fclose(ReadFile);
}

if i enter 2 into the week...
so it should be ask me twice of the attendance...
but the program ask me one time only..
and the calculation, it cannot detect the Attendance[x] ? or i assign wrongly?