main() {
book p;
int i;
FILE *fptr;
clrscr();
do {
printf("Welcome to book store\n");
printf("\nPlease select you choice\n");
line();
printf("[1].insert\n[2].delete \n[3].view\n[4].search\n[5].exit\n");
printf("Insert you choice : ");
scanf("%d", &i);
line();
if (i == 1) {
printf("insert book stroe\n");
fptr = fopen("d:\\text.txt", "ab");
do {
printf("\nbook id : ");
scanf("%d", &p.bid);
printf("\nbook name : ");
scanf("%s", p.bname);
//fwrite(&student[i], sizeof(student[i]), 1, fptr);
fprintf(fptr, "%d\t%s\t", p.bid, p.bname);
printf("Add another student(y/n)?: ");
line();
} while (tolower(getche()) == 'y');
fclose(fptr);
} else if (i == 2) {
int a = 0;
book ps[max];
printf("delete profile\n");
fptr = fopen("d:\\text.txt", "r+t");
fptr = fopen("d:\\text.txt", "w+t");
for (int b = 0; b < (b - 1); b++) {
if (choice != ps[b].bid) {
fprintf(fptr, "%d\t%s\n", ps[b].bid, ps[b].bname);
}
}
fclose(fptr);
} else if (i == 3) {
int a = 0;
book ps[max];
fptr = fopen("d:\\text.txt", "r+t");
while (!feof(fptr))
{
fscanf(fptr, "%d\t%s", &ps[a].bid, ps[a].bname);
a++;
}
fclose(fptr);
printf("view data\n\n");
for(i=0;i<a-1;i++){
printf("%d\t%s\n",ps[i].bid,ps[i].bname);
}
} else if (i == 4) {
int x = 0;
int choice;
book ps[max];
fptr = fopen("d:\\text.txt", "r+t");
while (!feof(fptr))
{
fscanf(fptr, "%d\t%s", &ps[x].bid, ps[x].bname);
x++;
}
//fclose(fptr);