AS per previous thread. This is supposed to read from file which has data

1001 1 2 (PatientID, day, session)
1002 2 4

To display to screen the corresponding appts. for the session and date together which total appointments

e.g.
Mon Tues Wed Thurs Fri
9.30 - 11.00am 1 2 1 2 3


etc


Total Appointments: 50

Any help would be appreciated.

SHARON




#define APP_FILE "A:\\PT2TS1VO.DAT"

#define MAX_SESSIONS 4
#define MAX_DAYS 5
#define START_LINE 7

#include <stdio.h>
#include <conio.h>
#include <string.h>


/*function prototypes */
void display_heading(char Head[], int Colours);
void display_col_headings(void);

void find_session(int Session, char SessionTime[]);
void fill_appoint_array(int Appoint[][MAX_DAYS]);
void display_appoint_array(int Appoint[][MAX_DAYS]);

void display_prompt(char Prompt[], int Colour);
void error_message(char ErrMsg[]);



FILE *fpt;



int main (void)

{
int Appoint[MAX_SESSIONS][MAX_DAYS]={0};
char SessionTime[30];
int Session;


clrscr();
display_heading("Appointments Program",YELLOW);

if ((fpt = fopen(APP_FILE, "r")) == NULL)
error_message("ERROR -- Cannot open appointment file for input");
else
{
fill_appoint_array(Appoint);
display_appoint_array(Appoint);

fclose(fpt);
}

display_prompt("Press <Enter> to exit program... ", YELLOW);
getch();
return (0);

}



void display_heading(char Head[], int Colour)
{
int I, HPos;
int const SCREEN_LENGTH = 80;

clrscr();

HPos = ((SCREEN_LENGTH - strlen(Head))/2);
textcolor(Colour);
gotoxy(HPos,1);
cprintf("%s", Head);
gotoxy(HPos,2);

for (I = 0; I < strlen(Head); I++)
cprintf("=");

return;
}




void display_col_headings(void)
{
gotoxy(28,5);
textcolor(WHITE);
cprintf("%-10s%-10s%-10s","MON","TUE","WED");
cprintf("%-10s%-10s","THU","FRI");

gotoxy(28,6);
cprintf("%-10s%-10s%-10s","---","---","---");
cprintf("%-10s%-10s","---","---");

return;

}


void fill_appoint_array(int Appoint[][MAX_DAYS])
{
int Status, Session, Day,TotalAppoint=0;
char PatientID[5];

Status=fscanf(fpt,"%s%d%d",PatientID,&Session,&Day );

while(Status!=EOF)
{
TotalAppoint++;
Status=fscanf(fpt,"%s%d%d",PatientID,&Session,&Day );

}
gotoxy(43,15);
textcolor(WHITE);
cprintf("Total Appointments: ");

textcolor(YELLOW);
cprintf("%d",TotalAppoint);

return;
}




void display_appoint_array(int Appoint[][MAX_DAYS])
{
int Session, Day, LineNum, Status;
int TotalAppoint = 0;
char SessionTime[30];

LineNum = START_LINE;
display_col_headings();

for(Session=0;Session<MAX_SESSIONS;Session++)
{
find_session(Session,SessionTime);
gotoxy(4,LineNum);
printf("%s",SessionTime);


gotoxy(18,LineNum);
for(Day=0;Day<MAX_DAYS;Day++);
{
printf("%12d",Appoint[Session][Day]);
getch();
}
LineNum++;

}


return;

}

void find_session(int Session, char SessionTime[])
{
if(Session==0)
strcpy(SessionTime, "9:00-10:30am");
else
if(Session==1)
strcpy(SessionTime,"11:00-12:30pm");
else
if(Session==2)
strcpy(SessionTime,"1:30-3:00pm");
else
if(Session==3)
strcpy(SessionTime,"3:30-5:00pm");

return;
}

void display_prompt(char Prompt[], int Colour)
{
gotoxy(1,23);
clreol();
textcolor(Colour);
fflush(stdin);
cprintf("%s",Prompt);

return;

}



void error_message(char ErrMsg[])
{
gotoxy(1,24);
clreol();
textcolor(RED+BLINK);
fflush(stdin);
cprintf("\a%s - Press a key to continue",ErrMsg);
getch();
gotoxy(1,24);
clreol();

return;

}