Here is my code i wrote for storing details of my apps but i think i went nuts in logic so please help me with the program
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
struct app
{
int id;
char name[200];
int price;
int instore;
};
}
fclose(fp);
}
void addappdetails()
{
FILE *fp;
struct app newapp;
fp=fopen("appdata.dat","a");
if(fp==NULL)
{
printf("\nERROR IN OPENING FILE...");
exit(0);
}
printf("\n Enter app ID(integer)");
scanf("%d",&newapp.id);
printf("\n Enter app name(max 200 chars)");
scanf("%s",&newapp.name);
printf("\n Enter 0 if not in app-store and 1 if it is in app-store");
scanf("%d",&newapp.instore);
fprintf(fp,"%d \t%s\t%d\n",newapp.id,newapp.name,newapp.instore);
fprintf(fp,"%d",0);
fclose(fp);
printf("\n Successfully added in database");
}
void removeappdetails()
{
FILE *fp,*fptr;
struct app delapp;
int icd,found=0;
fp=fopen("appdata.dat","r");
if(fp==NULL)
{
printf("\nERROR IN OPENING FILE...");
exit(0);
}
fptr=fopen("temp.dat","w");
if(fptr==NULL)
{
printf("\nERROR IN OPENING FILE...");
exit(0);
}
printf("\nEnter the app id to delete");
scanf("%d",&icd);