Code:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define MAX_TBL_SIZE 30, MIN_STOCK_LEVEL 10
int index, number, input_item_id, input_item_stock, ItemId, Stock, Sufficient,
qty_sold, qty_new, input_item_id;;
float UnitPrice;
char file_name[100];
int num, r, c;
void ActionCode(int [8]);
void input(int input_item_id[index], int input_item_stock[index],
float UnitPrice[index]);
void CURRENTSTATUS(int ItemId[index], int Stock[index], int UnitPrice[index],
char Sufficient);
int main(void) {
FILE *ifp;
fprintf(stderr, "Enter the name of the input file: \n");
fscanf(ifp, "%d", &num);
ifp = fopen("file_name", "r");
ActionCode([8]);
input(input_item_id, input_item_stock, UnitPrice);
CURRENTSTATUS(ItemId, Stock, UnitPrice, Sufficient);
system("PAUSE");
return 0;
}
void input(int input_item_id[index], int input_item_stock[index], float
UnitPrice[index]){
while(input_item_id[index] != 0 && input_item_stock[index] != 0
&& UnitPrice[index] != 0){
fscanf(ifp, "%d", &input_item_id[index]);
fscanf(ifp, "%d", &input_item_stock[index]);
fscanf(ifp, "%f", &UnitPrice[index]);
index++;
}
void CURRENTSTATUS (int ItemId[index], int Stock[index], int
UnitPrice[index], char Sufficient){
if(input_item_stock < MIN_STOCK_LEVEL)
fprintf(stdout, "No", &Sufficient);
else
fprintf(stdout, "Yes", &Sufficient);
fprintf(stdout, "CURRENT STATUS\n");
fprintf(stdout, "Id\tStock\tPrice\tSufficient\n");
fprintf(stdout, "%d\t%d\t%.2f\t%c\n", ItemId[index], Stock[index],
UnitPrice[index], Sufficient);
void ActionCode(int *){
int [8] = {1, 2, 3, 4, 5, 6, 7, 8};
while ((c =fgetc(ifp)) != EOF) {
int number=1;
switch (number){
while(number != 0){
case 1:
CURRENTSTATUS(ItemId, Stock, UnitPrice, Sufficient);
break;
case 2:
if(Stock[index] == 0)
fprintf(stdout, "There is no item with id %d.\n",
ItemId[index]);
break;
case 3:
fprintf(ofp, "After sale, there are %d items with id %d.\n",
qty_sold, ItemId);
if(qty_new < MIN_STOCK_LEVEL){
fprintf(stdout, "This product needs to be reordered.\n");
}
break;
case 4: /* input_item_id == 1 */
fprintf(ofp, "After purchase, there are %d items with id %d.\n",
qty_new[index],ItemId[index]);
if(qty_new < MIN_STOCK_LEVEL){
fprintf(stdout, "This product needs to be reordered.\n");
}
break;
case 5:
if(qty_new < MIN_STOCK_LEVEL){
fprint(stdout, "Items to be reordered\n");
fprint(stdout, "%d\n", ItemId[index]);
}
break;
case 6:
if (qty_new <= 1){
printf("Lowest Stock: Only %d items left with id %d.\n",
qty_new[index], ItemId[index]);
fprintf(stdout, "URGENT ORDER - this product needs to be"};
fprintf(stdout, "re-ordered\n");
fprintf(stdout, "immediately.\n");
}
break;
case 7:
Unitprice[index] += (Stock[index]) * (UnitPrice[index]);
UnitPrice[index] += (Stock[index]) * (UnitPrice[index]);
fprintf(stdout, "Total price of all the items: $.2f\n",
UnitPrice[index]);
break;
case 8:
fprintf(stdout, "Good Bye!\n");
break;
}
}
}
}
Followings are error messages: