hi, can someone please post a working code for this program. thanks please. having touble big time with this program. please.
This is a discussion on Retail Management - the 3rd split within the C Programming forums, part of the General Programming Boards category; hi, can someone please post a working code for this program. thanks please. having touble big time with this program. ...
hi, can someone please post a working code for this program. thanks please. having touble big time with this program. please.
Doubtful. We're not here to build your programs, we're here to help you.
Code:#include <stdio.h> #include <stdlib.h> #define MAX_TBL_SIZE 30 #define MIN_STOCK_LEVEL 10 #define MAXSTRING 100 int count, stock[MAX_TBL_SIZE], input_item_id[MAX_TBL_SIZE], input_stock[MAX_TBL_SIZE]; float Price[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 Price[MAX_TBL_SIZE]); void CURRENTSTATUS (int ItemId[count], int Stock[count], int Price[count], char Sufficient); int main(void) { char file_name[MAXSTRING]; char *inputfile, *outputfile; int num, r, c; int ActionCode, ItemId, Stock, Price, Sufficient, qty_sold, qty_new,input_item_id, unit_price; FILE *ifp; FILE *ofp; inputfile = (char *) malloc (25); fprintf(stderr, "Enter the name of the input file: \n"); //retail.txt scanf("%s", inputfile); // printf("%s",inputfile); //fprintf(outputfile, "num = %d\n", num); ifp = fopen(inputfile, "r"); if(ifp==NULL) { printf("Error: can't open file.\n"); return 1; } else { printf("File opened successfully.\n"); } ofp = fopen(outputfile, "w"); //system("PAUSE"); system ("pause"); return 0; } void input(FILE *ifp, int input_item_id[count], int input_stock[count], int c, float Price[count]) { while(input_item_id[count] != 0 && input_stock[count] != 0 && Price[count] != 0) { fscanf(ifp, "%d", &input_item_id[count]); fscanf(ifp, "%d", &input_stock[count]); fscanf(ifp, "%f", &Price[count]); count++; } void ActionCode(int *);{ int number=1; switch (number) { case 1: { void CURRENTSTATUS (int input_item_id[count], int Stock[count], int Price[count], char Sufficient) { printf("CURRENT STATUS\n"); printf("Id\t Stock\t Price\t Sufficient\n"); printf("%d\t%d\t%.2f\t%c\n", input_item_id, Stock, Price,Sufficient); } } break; case 2: { if(input_stock[count] == 0); { printf("There is no item with id %d.\n", input_item_id[count]); } } break; case 3: { printf("After sale, there are %d items with id %d.\n",stock[count], input_item_id[count]); if(stock[count] < MIN_STOCK_LEVEL) { printf("This product needs to be reordered.\n"); } } break; case 4: { printf("After purchase, there are %d items with id %d.\n", stock[count],input_item_id[count]); if(stock[count] < MIN_STOCK_LEVEL) { printf("This product needs to be reordered.\n"); } } break; case 5: { printf("Items to be reordered\n"); printf("%d\n", input_item_id[count]); } break; case 6: { if (stock[count] <= 1) printf("Lowest stock: Only %d items left with id %d.\n", stock[count], input_item_id[count]); printf("URGENT ORDER - this product needs to be re-ordered immediately\n"); } break; case 7: { Price[count] += stock[count] * Price[count]; printf("Total price of all the items: $.2f\n", Price[count]); } break; case 8: { printf("Good Bye!\n"); } break; } } }
You'll need to change this part, to something like this:
So the "action code number is supposed to give the user info on the number of that item in stock, by looking it up in the file, and printing out the info?Code:void ActionCode(int number ) { switch (number) { case 1: { etc.
Is the ActionCode function the only one that doesn't work?