--- julie ann enriquez roque <[EMAIL PROTECTED]>
wrote:
> #include<stdio.h>
> #include<conio.h>
> #include<string.h>
>
> struct libraryInfo
> {char code[10];
> char title[50];
> char author[20];
> int no_copies;
> };
>
> int enterOption(void);
> void bookProfile(FILE*);
> void transaction(FILE*);
> void report(FILE*);
> int enterChoice(void);
> void addRecord(FILE*);
> void editRecord(FILE*);
> void deleteRecord(FILE*);
> void borrowedBook(FILE*);
> void returnedBook(FILE*);
> int enterPick(void);
>
>
> int main()
> {FILE * cfPtr;
> int option;
>
> if((cfPtr=fopen("library.info","r+"))==NULL)
> printf("File could not be opened.\n");
> else{
> while((option=enterOption())!=5)
> {switch(option)
> {case1:
> bookProfile(cfPtr);
> break;
> case2:
> transaction(cfPtr);
> break;
> case3:
> report(cfPtr);
> break;
> case4:
> printf("End of Run\n");
> break;
> }
> }
> fclose(cfPtr);
> }
> return 0;
> }
>
>
> void bookProfile()
> {FILE * cfPtr;
> int choice;
>
> if((cfPtr=fopen("library.info","r+"))==NULL)
> printf("File could not be opened.\n");
> else{
> while((choice=enterChoice())!=5)
> {
> switch(choice)
> {case1:
> addRecord(cfPtr);
> break;
> case2:
> editRecord(cfPtr);
> break;
> case3:
> deleteRecord(cfPtr);
> break;
> case4:
> main();
> break;
> }
> }
> }
>
> void transaction()
> {FILE * cfPtr;
> int pick;
>
> if((cfPtr=fopen("library.info","r+"))=NULL)
> printf("File could not be opened.\n");
> else{
> while((pick=enterPick())!=4)
> {
> switch(pick)
> {case1:
> borrowedBook(cfPtr);
> break;
> case2:
> returnedBook(cfPtr);
> break;
> case3:
> main();
> break;
> }
> }
> fclose(cfPtr);
> }
> return 0;
> }
>
> void record()
> {FILE * cfPtr;
>
> if((cfPtr=fopen("library.info","r"))==NULL)
> printf("File could not be opened.\n");
> else{
> printf("%s%s%s%d","Code","Title","Author","No.
> of Copies");
>
>
fscanf(cfPtr,"%s%s%s%d",code,title,author,no_copies);
>
> while(!feof(cfPtr)){
> printf("%s%s%s%d\n",code,title,author,no_copies);
>
>
fscanf(cfPtr,"%s%s%s%d",code,title,author,no_copies);
> }
>
> fclose(cfPtr);
>
> }
> return 0;
> }
>
>
> void addRecord()
> {FILE * cfPtr;
> int choice;
>
> if((cfPtr=fopen("library.info","r+"))==NULL)
> printf("File could not be opened.\n");
> else{
> while((choice=enterChoice())!=3)
> {
> switch(choice)
> {case1:
> add(cfPtr);
> break;
> case2:
> bookProfile(cfPtr);
> break;
> }
> }
> fclose(cfPtr);
> }
>
>
> void editRecord()
> {FILE * cfPtr;
> int choice;
>
> if((cfPtr=fopen("library.info","r+"))==NULL)
> printf("File could not be opened.\n");
> else{
> while((choice=enterChoice())!=3)
> {
> switch(choice)
> {case1:
> edit(cfPtr);
> break;
> case2:
> bookProfile(cfPtr);
> break;
> }
> }
> fclose(cfPtr);
> }
>
>
> void deleteRecord()
> {int choice;
> FILE*cfPtr;
>
> if((cfPtr=fopen("library.info","r+"))==NULL)
> printf("File could not be opened.\n");
> else{
> while((choice=enterChoice())!=3)
> {
> switch(choice)
> {case1:
> delete(cfPtr);
> break;
> case2:
> bookProfile(cfPtr);
> break;
> }
> }
> fclose(cfPtr);
> }
>
>
> void add()
> {FILE * cfPtr;
> char ans;
> cfPtr=fopen("libraryInfo","w");
> do
> {printf("Enter book code:");
>
=== message truncated ===
What is the problem? Be specific
Mickey M.
Construction Partner Inc.
http://www.constructionpartner.com
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs