Question: write a C program on this Create an Inventory Control Program, called ICP.exe. This program will provide the user with a menu of actions to
write a C program on this Create an Inventory Control Program, called ICP.exe. This program will provide the user with a menu of actions to control inventory, which include: list the inventory, create an item, add inventory, remove inventory, delete item, import and export database. An inventory item has a: Unique ID, Part NO, Names, Quantity, and Sale Price, and Unit Price. Load a database with the following items: 1. SNK809a Seiko Automatic Men's Watch, 10, $75, $70. 2. SR400 Yamaha 400cc Motorcycle, 3, $5,999, $4,000. 3. Soundlink-Coral Bose Bluetooth Speaker in Coral Red, 20, $129, $89. Demonstrate loading/creating a database of inventory, creating new items, adding to inventory, removing from inventory, and saving the database. Capture your output with the snipping tool. A menu might look like the following, but the student is free to create a different interface, if it is more intuitive. c:\users\dbs0011\icp.exe Welcome to the Inventory Control Program! select from the following (L)ist, (C)reate, (A)dd, (R)emove, (I)mport, or (E)xport:> I enter the DB name to import:> first.db first.db imported. select from the following (L)ist, (C)reate, (A)dd, (R)emove, (I)mport, or (E)xport:> I Build the Import and Export functions last as we will not cover files until right before the end of this project. Use dynamic memory allocation for your records. Each interface option should be a separate function. Use structures to define your inventory items. Use separate C files to encapsulate your user interface, data storage and test functions. I have to use the code given below in this format. I have been stuck using Xcode and i have a few bugs. I would appreciate if you can view my code and errors to help me get this up and running. Here is all my code: the first of 3 is a header file: #define TRUE 1 #define FALSE 0 typedef struct { int id; char name[50]; char partNo[30]; float price; float cost; int quantity; }item_t; int createItem(); int writeInventory(); item_t *readInventory(); int printInventory(void); with 3 errors before the last line of code saying This function declaration is not a prototype Next file linked to the header is inventory2.c #include #include #include #include "inventory2.h" item_t *inventory[30]; int next=0; int getNextId() { static int id=0; return id++; } void printItem(item_t *p){ printf(" \tpart name: %s", p->name); printf(" \tpart number: %s", p->partNo); printf("n\tpart quantity: %d", p->quantity); printf(" \tpart price: %f", p->price); printf("n\t\tpart cost: %f", p->cost); } printInventory() { register int i; for(i=0; iid=getNextId(); printf(" \tEnter part name: "); fgets(p->name, 50, stdin); p->name[strlen(p->name)-1] = '\0'; printf(" \tEnter part number "); fgets(p->partNo, 30, stdin); p->partNo[strlen(p->partNo)-1] = '0'; printf(" \tEnter part quantity: "); fgets(buf, 50, stdin); buf[strlen(buf)-1] = '\0'; p->quantity = atoi(buf); printf("n\tEnter part price: "); fgets(buf, 50, stdin); buf[strlen(buf)-1] = '\0'; p->price = (float) atof(buf); printf("n\tEnter part cost: "); fgets(buf, 50, stdin); buf[strlen(buf)-1] = '\0'; p->cost = (float) atof(buf); inventory[next++] = p; return TRUE; } int writeInventory() { FILE *fp; int num, i; item_t*p; fp = fopen("inventory.db", "rb"); for(i=0; i #include #include "inventory2.h" int mainMenu (){ char buf[50], *p; buf[0] = '\0'; printf(" \tSelect from the following commandsL (L)ist, (A)dd, (R)emove, (I)mport, (E)xport, or (Q)uit: "); fgets(buf, 50, stdin); buf[strlen(buf) -1] = '\0'; p = strupr(buf); switch(*p) { case 'L': printInventory(); break; case 'A': createItem(); break; case 'R': case 'I': readInventory(); break; case 'E': case 'Q': writeInventory(); return FALSE; default: printf(" \t\tERROR: invalid option selected! "); } return TRUE; } int main (void) { item_t *i; int loop = TRUE; while (loop) { loop= mainMenu(); } return 0; } line 22 error: p = strupr(buf); This function declaration is not a prototype Incompatible integer to pointer conversion assigning to 'char *' from 'int' Implicit declaration of function 'strupr' is invalid in C99 item_t *i; line 46 error: unused variable i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
