-
Notifications
You must be signed in to change notification settings - Fork 0
/
sanctionLoan.h
53 lines (47 loc) · 1.32 KB
/
sanctionLoan.h
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
#include "loanapplication.h"
void sanctionLoan()
{
FILE *ptr, *ptr1, *ptr2;
long acc_number;
long flag;
flag = 0;
ptr = fopen("List", "rb");
ptr1 = fopen("LoanRequest", "rb");
ptr2 = fopen("Listtemp", "wb");
if(ptr == NULL || ptr1 == NULL || ptr2 == NULL)
{
exit 0;
}
clearscr();
printf("Enter the account number whose loan would get sanctioned: ");
scanf("%ld", &acc_number);
while(fread(&ACC, sizeof ACC, 1, ptr))
{
if(ACC.acc_number == acc_number)
while(fread(&LD, sizeof LD, 1, ptr1))
{
if(LD.acc_number == acc_number)
{
//when the account number matches, we update the details of the user
flag = 1;
ACC.emi_amount = LD.emi_amount;
ACC.loan_amount = LD.loan_amount;
ACC.time_period = LD.time_period;
ACC.previous_loan = true;
}
}
fwrite(&ACC, sizeof ACC, 1, ptr2);
}
if(!flag)
{
printf("Sorry no account with the entered account number could be found that has applied for loan");
}
//closing the file pointers
fclose(ptr);
fclose(ptr1);
fclose(ptr2);
remove("List");
rename("Listtemp", "List");
printf("\n\nPress any key to continue...");
getch();
}