WAZ UP EVERYONE.
I am making an inventory system that manages items you know adds items, removes and etc.
SO ive been able to do a lot of things so far like add new item and quit and ive made a menu so i can navigate functions.
But ive run into problems i cant get the rest of the code to work can you please help me? when i do the other ones it doesnt work
Code:
#include <stdio.h>
#include <string.h>
char itemName [50];
float itemPrice = 0;
float total = 0;
int numberOfItems = 0;
int number = 0;
char scanItem [50];
float scanPrice = 0;
void add(float aPrice,char aName [50]);
float getTotal();
float calaverage();
char nameforitem[20];
int amount;
char unit[10];
void add(struct ItemsList * detail , int number)
{
int i=0,n=1,x,error;
for (i=0; i<number; i++,n++)
{
printf(" ItemName %d:",n);
scanf("%19s",&detail[i].ItemName);
do
{
printf("Amount:");
fflush(stdin);
error = scanf("%d",&detail[i].amount);
if (error!=1)
printf("Wrong form. Try again!");
}
while (error!=1);
printf("Unit:");
scanf("%9s",&detail[i].unit);
}
int main(void)
{
struct ItemsList *points;
int numberOfItem;
printf("How many items:");
scanf("%d",&numberOfItem);
points=(struct ItemsList*) malloc (numberOfItem * sizeof(struct ItemsList*));
printf("List of Items...\n");
int k;
for (k=0; k<numberOfItem; k++)
{
printf("%-20s%-10d%-20s\n", points[k].Item Name, points[k].amount, points[k].unit);
};
while (1)
{
printf("1. Add new Item\n");
printf("2. Print amount of items stored\n");
printf("3. Remove an item\n");
printf("4. Display info on items\n");
printf("5. Search for items\n");
printf("6. Check for given items in storage\n");
printf("7. Print price for items stored\n");
printf("8. Manage items\n");
printf("9. Save storage to file\n");
printf("10. Load storage from file\n");
printf("11. Quit\n"); printf("Enter Option: ");
scanf("%d",&number);
if(number==1)
{
printf ("Enter item name: ");
scanf ("%s", scanItem);
printf ("\n");
printf ("\nEnter Price: ");
scanf("%f",&scanPrice);
add(scanPrice,scanItem);
}
else if (number == 2) printf ("\nManage items %s\n"),
scanf("20%s-20%f", scanItem, &scanPrice);
else if (number == 3)
printf("Enter the Item Name wish you want to delete \n");
scanf ("%s", scanItem);
if ( itemName >= itemName )
printf("Deletion not possible.\n");
else
{
printf("Delete item")
scanf("delete item")
}
else if (number == 4)
else if (number == 5)
printf("Search for items\n")
else if (number == 6)
else if (number == 7) printf ("Total is %f\n\n", getTotal());
else if (number == 8)
else if (number == 9)
else if (number == 10) printf ("The average is %f\n\n", calaverage ());
else if (number == 11) break; else printf("Invalid Option\n");
}
return 0;
}
void add(float aPrice,char aName [50])
{
strcpy (itemName, aName);
itemPrice = aPrice;
total=total+aPrice;
numberOfItems++;
}
float getTotal()
{
return total;
}
float calaverage()
{
return total/numberOfItems;
}