I missed one on this line:
while ((attempt == current_attempt) && (group = current_group) && (group <= 99))
You also need to change all
group <= 99
to
group < 99
Here is an improved version.
Code:
#include<stdio.h>
#include<conio.h>
int main()
{
int group,
attempt,
group_total,
current_attempt,
current_group,
attempt_total;
FILE *ch7d = fopen("ch7d.dat", "r");
if (ch7d == NULL)
{
printf("Unable to open file.\n");
return 0;
}
fscanf(ch7d, "%d %d", &group, &attempt);
printf("Student Assessment Attempt Report\n");
while (group < 99)
{
group_total = 0;
current_group = group;
printf("\nGroup %d\n", current_group);
while (group == current_group && group < 99)
{
current_attempt = attempt;
attempt_total = 0;
/*stuck from here*/
while ((attempt == current_attempt) && (group == current_group) && (group < 99))
{
attempt_total += 1;
fscanf(ch7d, "\n%d %d", &group, &attempt);
//getch();
}
if (current_attempt == 2)
{
printf("Both ");
}
else if(current_attempt == 1)
{
printf("One ");
}
else
{
printf("None ");
}
printf("%d\n", attempt_total);
group_total += attempt_total;
}
printf("Group total:%d\n", group_total);
}
fclose(ch7d);
getch();
return 0;
}