hi everyone
i am trying to write a program for a library system that allow stuff to add, remove, view and delete customer. i try to use file to store data and i open the file in mode read then i store then i put the content of the file into a struture. now the problem started it is only showing me haft of the content and here is the coding.
#include <stdio.h>
# include <windows.h>
# include <stdlib.h>
#include<string.h>
#include<conio.h>
void transaction();
void Book();
void view(int x,struct books eli[20]);
struct books{
char name[22], book[25],date1[10], date2[10],id[7],bid[7];
};
int main(void)
{
struct books eli[20];
int num,ctr=0,index=0;
FILE *fp;
fp = fopen("database.txt","r");
for(ctr=0;fscanf(fp,"%s %s %s %s %s %s", eli[ctr].name,eli[ctr].id,eli[ctr].book,eli[ctr].bid,eli[ctr].date1,eli[ctr].date2)!=EOF;ctr++)
{
fscanf(fp,"%s %s %s %s %s %s", eli[ctr].name,eli[ctr].id,eli[ctr].book,eli[ctr].bid,eli[ctr].date1,eli[ctr].date2);
index=ctr+index;
}
fclose(fp);
do
{
system("cls");
printf("\n\t\t***************************************");
printf("\n\t\t\t\t\t\t\t\t\t\t\t\t\t Welcome To BOOK MENU ");
printf("\n\t\t***************************************\n");
printf("\n\t\t1. View Books");
printf("\n\t\t2. Exit");
printf("\n\t\t***************************************");
printf("\n\t\t Choice:");
scanf("%d", &num);
switch(num)
{
case 1:
view(index,eli);
break;
case 2:
return 0;
break;
default :
printf(" \n\t\t wrong value !!!");
break;
}
}while(num!=2);
Sleep(2000);
}
void view(int x,struct books eli[20])
{
printf("%d",x);
int ct;
for(ct=0;ct<x;ct++)
{
printf("\n%-13s %-13s %-13s %-13s %-13s %-13s",eli[ct].name,eli[ct].id,eli[ct].book,eli[ct].bid,eli[ct].date1,eli[ct].date2);
}
Sleep(5000);
}