Source code
#include <stdio.h>
#include<string.h>
struct product
{
char name[100];
int id;
int price;
char discription[100];
int discount;
int total_price;
};
struct product p[100];
int index=0;
int menu()
{
printf("Press 1 to Show All product
");
printf("press 2 to Add Product
");
printf("Press 3 to Delete Product
");
printf("Press 4 to Search a product
");
printf("Press 5 to count all product
");
printf("Press 10 to Exit
");
}
int showallproduct()
{
int i=0;
FILE *fp;
fp=fopen("showallproduct.txt","w");
if(index==0)
{
printf("No Data
");
}
else
{
for(i=0; i<index; i++)
{
fprintf(fp,"Name: %s
",p[i].name);
fprintf(fp,"ID: %d
",p[i].id);
fprintf(fp,"product Price: %d
",p[index].price);
fprintf(fp,"Description: %s
",p[i].discription);
fprintf(fp,"discount: %d
",p[index].discount);
fprintf(fp,"Total Balance: %d
",p[index].total_price);
}
}
return 0;
}
int addproduct()
{
int i=0,j;
int flag =0;
printf("Please Enter The Product name:
");
fflush(stdin);
gets(p[index].name);
while(p[index].name[i] != '