mercredi 4 mars 2015

Entering no ID.- Attendance Record System


Vote count:

0




This program asks students to enter their ID to update their attendance record in a file. What I'm not sure about is, I want if students haven't entered their ID, it will print "absent" Below is a snippet.



ufile= fopen("C:\\Users\\Student\\Desktop\\update.txt","w");
fprintf(ufile,"First Name Last Name ID Status Time Arrived");

while (j < x){
Next:
printf("Please enter your ID: ");
scanf("%d", &id_);

for (i = 0; i < x; i++) {



if(array[i].code == id_){

printf("Are you %s %s?\n", array[i].fname, array[i].lname);
printf("[y/n only]: ");
scanf(" %c", &ans);

switch (ans){
case 'y':
strcpy(status, "Present");
if((int)buf < ((int)"08:00" )){
printf("Early.\n");

}
else{
printf("You are late for school.\n");
}


printf("Continue?\n[y/n only]:");
scanf(" %c", &ans1);

fprintf(ufile,"\n");
printf("You are early for school.\n");
fprintf(ufile,"%-15s%-14s%2d%12s ",array[i].fname, array[i].lname, array[i].code, status);
fprintf(ufile,"%16s",(buf));


if(ans1 == 'y'){
break;
case 'n':
goto Next;
break;
default:
printf("invalid answer");
}
if (ans1 == 'n'){
exit(EXIT_SUCCESS);
}
}// end of case



}//end of main if statement checking for ID

j++;//increments j by 1 in the while loop

}//end of while loop
fclose(ufile);//closese file called ufile

getch();
return 0;
}


asked 13 secs ago







Entering no ID.- Attendance Record System

Aucun commentaire:

Enregistrer un commentaire