EnterBook.cpp


This code is the implementation of the interface of Enter books. It calls two functions:
  1. appending a new book to the book file data.txt and
  2. updating the index.
 ~wenchen/public_html/cgi-bin/351/week13/EnterBook.cpp 
#include  <fstream>
#include  <cstring>
  using namespace  std;

#include  "InsertBook.h"
#include  "InsertIndex.h"
int  main( int argc, char* argv[ ] ) {
  fstream  book;
  int      offset;

  book.open( "data.txt", fstream::in | fstream::out );
  book.seekp( 0, fstream::end );
  if ( ( offset = book.tellp( ) ) == -1 )  offset = 0;
  book.close( );
  InsertBook ( argv[1], argv[2], argv[3], argv[4] );
  InsertIndex( argv[2], offset );
}