-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverDueBooks.c
64 lines (45 loc) · 1.21 KB
/
overDueBooks.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>
#include <conio.h>
#include <time.h>
#include <windows.h>
#include "book.h"
#include "member.h"
#include "admin.h"
#include "menu.h"
#include "dataTypes.h"
#include "utilities.h"
void overDueBooks() {
SetConsoleTitle("Library System > Admin Menu > Over Due Books");
system("cls");
// declaring a variable of bookDataType so if found, it can be used
// no need for array
// reading from files will be instantly
borrowedBookDataType book;
FILE * borrowedBooks = fopen("borrowed-books.bin", "r");
// failure check
if(borrowedBooks==NULL) {
perror("\a\nError");
getche();
return;
}
bool found = false;
time_t todDate;
time(&todDate);
// read from original file
while( fread(&book,sizeof(borrowedBookDataType),1,borrowedBooks) ) {
if( difftime(todDate,book.dueDate)>=0 ) {
found = true;
showBookDetails(book.ISBN);
}
}
if(!found)
acpMsg("No overdue books found");
fclose(borrowedBooks);
getche();
fflush(stdin);
adminMenu();
}