Browse Source

Add feature to check eligibility for loan

remotes/origin/feature/loan-eligibility
Shivam Chaudhary 2 years ago
parent
commit
b9992a63ad
  1. 30
      src/checkLoanEligibility.c
  2. 10
      src/checkLoanEligibility.h

30
src/checkLoanEligibility.c

@ -0,0 +1,30 @@
#include "checkLoanEligibility.h"
#include "_file_information.h"
bool checkLoanEligibility(int user_id) {
// Eligible only when user is present in CustomerDataFile
bool keep_reading = true;
bool eligibility = false;
char buffer[MAX_LENGTH];
FILE *file = fopen(CUSTOMER_DATA_FILE, "r");
while(keep_reading) {
fgets(buffer, MAX_LENGTH, file);
if (feof(file)) {
keep_reading = false;
}
if(user_id == atoi(buffer)) {
eligibility = true;
keep_reading = false;
}
}
fclose(file);
return eligibility;
}

10
src/checkLoanEligibility.h

@ -0,0 +1,10 @@
#ifndef CHECKLOANELIGIBILITY_H_
#define CHECKLOANELIGIBILITY_H_
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
bool checkLoanEligibility(int user_id);
#endif
Loading…
Cancel
Save