Code:
#include <stdio.h>
#include <stdlib.h>
#define MAXRECS 100
#define MAXC 40
typedef struct InventoryRecord
{
char desc[MAXC];
float unitcost;
int quantity;
float stockvalue;
}InventoryRecord;
typedef InventoryRecord InventoryTable[MAXRECS];
void Validate_File_Open(FILE *report, FILE *inventory);
void getInventoryData(FILE *inventory, InventoryTable t, int *RecCount);
float calcItemValue(float unitcost, int quantity);
void Sort_By_Description(InventoryTable t, int SIZE, int i);
void swap(InventoryRecord *r1, InventoryRecord *r2);
void printReport(InventoryTable t, int SIZE);
void Flush(void);
int main()
{
InventoryTable myinven;
InventoryTable t;
int i, count;
FILE *report, *inventory;
report = fopen("Report.txt", "w");
inventory = fopen ("A:\\INV.DAT", "r");
Validate_File_Open(report, inventory);
getInventoryData(inventory, t, &count);
for(i=0; i<MAXRECS; i++)
/* Do you anywhere see the itemValue in the struct */
t[i].itemValue = calcItemValue(t[i].unitcost, t[i].quantity);
for(i = 0; i < MAXRECS; i++)
/* You where trying to assign a value to struct data member not to the struct array itself */
t[i] = i;
/* And you forgot to send one more parameter to this function */
Sort_By_Description(t, i , WHAT);
PrintReport(t, i);
/*InventoryRecord tempRec=t[i];
T[i]=t[i+1];
T[i+1]=tempRec; */
/*Void swap(InventoryRecord *r1, InventoryRecord *r2);
swap(&t[i], &t[i+1]*/
fclose(report);
fclose(inventory);
Flush();
printf("\n\n Press any key to terminate . . . \n");
getchar();
return 0;
}
This code needs lot of improvement. They where lots of syntax error. If you would have compiled, you would have come to know all of them. I have managed to take off quite a few for you.
And where are your function definitions for this program. Without that you can't use this program. And need writing them.
ssharish2005