???
#include <stdio.h>
#include <stdlib.h>
struct Medical_store
{
char name[100];
char composition[100];
int stock;
int price;
char location[100];
int retail;
int profit;
};
int main()
{
int choose;
int i;
int n_add;
printf("Enter :");
scanf("%d", &choose);
switch (choose)
{
case 1:
{
struct Medical_store *medicine;
FILE *medi_add;
medi_add = fopen("medicine.txt", "a");
printf("How many medicine do you want to add :\n");
scanf("%d", &n_add);
medicine = (struct Medical_store *)malloc(n_add * sizeof(struct Medical_store));
printf("Size of n is %lu\n", *medicine);
if (medicine == NULL || medi_add == NULL)
{
printf("Memory allocation failed \n");
exit(0);
}
else
{
for (i = 0; i < n_add; i++)
{
fprintf(medi_add, "%s %s %d %d %d %s", medicine[i].name, medicine[i].composition, &medicine[i].stock, &medicine[i].retail, &medicine[i].price, medicine[i].location);
}
}
fclose(medi_add);
}
break;
default:
printf("Defult");
exit(0);
}
return 0;
}