Code:
this is my program, the input for time in and time out is string because of the colon e.g. 08:00, and if possible i also want to store the time in and time out in the file day.txt ex. 08:00,17:00,17:30,17:30,08:03,17:00,17:30,17:30,08:00,12:00,17:30,17:30,07:45,17:05,17:30,17:30,07:59,17:20,17:30,17:30
pls. kindly check my work. tnx
#include<stdio.h>
#include<stdlib.h>
main()
{
FILE *fptr;
char x[5][9]={"Monday","Tuesday","Wednesday","Thursday","Friday"};
int i,y,a[5],b[5],total=0,total1=0;
char a1[5],b1[5];
fptr =fopen("day.txt","a");
clrscr();
for(i=0;i<5;i++)
{
printf("Enter time-in for %s: ",x[i]);
gets(a1);
printf("Enter time-out for %s: ",x[i]);
gets(b1);
fprintf(fptr,"%6s %6s",a1,b1);
fclose(fptr);
}
for(i=0;i<5;i++)
{
a[i] = atoi(a1[i]);
b[i] = atoi(b1[i]);
total = (b[i]-1) - a[i];
total1 += total;
}
printf("total no. of hrs for one week: %d",total1);
getch();
}