You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
618 B

  1. #include "checkLoanEligibility.h"
  2. #include "_file_information.h"
  3. bool checkLoanEligibility(int user_id) {
  4. // Eligible only when user is present in CustomerDataFile
  5. bool keep_reading = true;
  6. bool eligibility = false;
  7. char buffer[MAX_LENGTH];
  8. FILE *file = fopen(CUSTOMER_DATA_FILE, "r");
  9. while(keep_reading) {
  10. fgets(buffer, MAX_LENGTH, file);
  11. if (feof(file)) {
  12. keep_reading = false;
  13. }
  14. if(user_id == atoi(buffer)) {
  15. eligibility = true;
  16. keep_reading = false;
  17. }
  18. }
  19. fclose(file);
  20. return eligibility;
  21. }