Code:
#include <stdio.h>
#define MAX_TBL_SIZE 30
#define MIN_STOCK_LEVEL 10
#define MAXSTRING 100
int counter, stock[MAX_TBL_SIZE], input_item_id[MAX_TBL_SIZE], input_stock[MAX_TBL_SIZE]; float UnitPrice[MAX_TBL_SIZE];
void ActionCode(int *);
void input(FILE *ifp,int input_item_id[MAX_TBL_SIZE], int input_stock[MAX_TBL_SIZE], int c, float Unitprice[MAX_TBL_SIZE]);
void CURRENTSTATUS (int ItemId[counter], int Stock[counter], int UnitPrice[counter], char Sufficient);
int main(void) {
char file_name[MAXSTRING];
int num, r, c;
int ActionCode, ItemId, Stock, UnitPrice, Sufficient, qty_sold, qty_new,
input_item_id, unit_price;
FILE *ifp;
FILE *ofp;
fprintf(stderr, "Enter the name of the input file: \n");
fscanf(ifp, "%d", &num);
fprintf(ofp, "num = %f\n", num);
ifp = fopen("file_name", "r");
system("PAUSE");
return 0;
}
//Obtaining action code and use switch to process action
//Void function obtaining imput file
void input(FILE *ifp, int input_item_id[counter], int input_stock[counter], int c, float UnitPrice[counter]){
while(input_item_id[counter] != 0 && input_stock[counter] != 0
&& UnitPrice[counter] != 0){
fscanf(ifp, "%d", &input_item_id[counter]);
fscanf(ifp, "%d", &input_stock[counter]);
fscanf(ifp, "%f", &UnitPrice[counter]);
counter++;
}
while ((c=fgetc(ifp) != EOF)) {
/* Use a switch statement instead */
void ActionCode(int *);
int number=1;
switch (number){
case 1:
{
void CURRENTSTATUS (int input_item_id[counter], int Stock[counter],
int UnitPrice[counter], char Sufficient){
printf("CURRENT STATUS\n");
printf("Id\tStock\tPrice\tSufficient\n");
printf("%d\t%d\t%.2f\t%c\n", input_item_id, Stock, UnitPrice,
Sufficient);
}
break;
case 2:
if(input_stock[counter] == 0);
printf("There is no item with id %d.\n", input_item_id[counter]);
break;
case 3:
printf("After sale, there are %d items with id %d.\n",
stock[counter], input_item_id[counter]);
if(stock[counter] < MIN_STOCK_LEVEL){
printf("This product needs to be reordered.\n");
}
break;
case 4: /* input_item_id == 1 */
printf("After purchase, there are %d items with id %d.\n",
stock[counter],input_item_id[counter]);
if(stock[counter] < MIN_STOCK_LEVEL){
printf("This product needs to be reordered.\n");
}
break;
case 5:
print("Items to be reordered\n");
print("%d\n", input_item_id[counter]);
}
break;
case 6:
if (stock[counter] <= 1)
printf("Lowest stock: Only %d items left with id %d.\n",
stock[counter], input_item_id[counter]);
printf("URGENT ORDER - this product needs to be re-ordered immediately\n");
break;
case 7:
UnitPrice[counter] += stock[counter] * UnitPrice[counter];
printf("Total price of all the items: $.2f\n", UnitPrice[counter]);
break;
case 8:
printf("Good Bye!\n");
break;
}
}
}
Sorry if you told me a suggestion and I did it wrong, I try to understand best I can but all this stuff is so confusing to me. Right now if I try to compile this I get an error saying linker error undefined reference to print.