Master Menu - Links the Master Page
Columns . . . : Edit AMOTT/SRCFILE
SEU==>_______________________________________________________ A06
FMT C* .....C*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7
*************** Beginning of data *************************************
/* Project 6 - Compares a file (Customer.dat) containing a customer's
** preferrences against another file (Apts.dat) to determine whether
** each particular apartment has the features that fit what the
** customer wants. It presents a printout of the address of each
** apartment, as well as the number of matches and a message whether
** each apartment meets at least 80% of the customer's preferrences.
Author: Worthley ©
Date Completed: April 11, 1999
*/
/*======================================================================*/
#include
#include
int main ( void )
{
FILE *customer ;
char choice ;
FILE *apartment ;
char cust_array[30] ;
int x = 0 ;
int match = 0 ;
char addy = ' ' ;
char c ;
customer = fopen("d:\Customer.dat", "r") ;
if(customer == NULL)
{
printf("File not found.\n") ;
return 1 ;
}
for(x = 0; x < 30; x++)
{
fscanf(customer, "%c", &cust_array[x]) ;
}
fclose(customer) ;
apartment = fopen("d:\Apts.dat", "r") ;
if(apartment == NULL)
{
printf("File not found.\n") ;
return 1 ;
}
printf(" Address Score Satisfactory\n") ;
printf("-----------------------------------------------------------\n") ;
c = fscanf(apartment, "%c", &choice) ;
while(c != EOF)
{ /* Begin While loop */
if(cust_array[0] == choice)
{
match++ ;
}
for(x = 1; x <= 29; x++)
{
fscanf(apartment, "%c", &choice) ;
if(cust_array[x] == choice)
{
match++ ;
}
} /* End While loop */
fscanf(apartment, "%c", &addy) ;
while(addy != '\n')
{
printf("%c", addy) ;
fscanf(apartment, "%c", &addy) ;
}
printf(" %2i", match) ;
if(match >= 24)
{
printf(" POSSIBLE\n") ;
}
else if(match <= 23)
{
printf(" NO\n") ;
}
match = 0 ;
addy = ' ' ;
c = fscanf(apartment, "%c", &choice) ;
}
fclose(apartment) ;
return 0 ;
}
/* End of Source */
Copyright ©1998 - 2001 J. Browning - All rights reserved.
Master Menu - Links the Master Page