I have been working on this program, searched this board and others to try and find out how to rewrite the following code because it doesn't work correctly:
Code:
int initialization(struct CUST_INFO custRecs[LIMIT_SIZE],
FILE * custFilePtr,
struct ORDER_INFO orderRecs[LIMIT_SIZE],
FILE * orderFilePtr, FILE * processFilePtr, int *pageNo);
Code:
howMany = initialization(custRecs, processFilePtr,
orderRecs, orderFilePtr, processFilePtr,
&pageNo);
Code:
int initialization(struct CUST_INFO custRecs[LIMIT_SIZE],
FILE * custFilePtr, struct ORDER_INFO orderRecs[LIMIT_SIZE],
FILE * orderFilePtr, FILE * processFilePtr, int *pageNo)
{
int k = 0;
char inputBuffer[1024] = {0};
while ((k < LIMIT_SIZE) && (fgets(inputBuffer, 1024,
custFilePtr)!= NULL))
{
sscanf(inputBuffer, "%9c %10c %10c %10c %25c %25c %15c %25c\n",
&custRecs[k].CustomerId, &custRecs[k].CustomerFirstName,
&custRecs[k].CustomerMiddleName, &custRecs[k].CustomerLastName,
&custRecs[k].CustomerAddress, &custRecs[k].CityStateZip,
&custRecs[k].CustomerPhoneNo, &custRecs[k].CustomerEmailAddress);
}
while ((k < LIMIT_SIZE) && (fgets(inputBuffer, 1024,
orderFilePtr)!= NULL))
{
sscanf(inputBuffer, "%9c %i %i %i %f\n",
&orderRecs[k].orderId,
&orderRecs[k].width,
&orderRecs[k].length,
&orderRecs[k].carpetCharge,
&orderRecs[k].discount);
k++;
}//end while loop
if(k == 0)
{
printf("Read All Records 1\n");
}
GetTopLine(processFilePtr);
PrintHeadings(pageNo, processFilePtr);
return k;
}//end initialization
The above code does not read all of the files
Thanks for any help.