passing a structure to a function with an array that dynamically allocates the structure

#include <iostream> // For Input and Output
#include <iomanip> // For Output manipulation
#include <fstream> // For file stream

using namespace std;

struct BookRecord // Declared Structure
{
string title;
string author;
int ISBN;
bool status;
};

int menuChoice; // Variable to hold user input on Menu options
void recordArray(BookRecord *); // Enter and save a new book record
void srchDisplay(); // Search for a book by title or author and display it
void srchDelete(); // Search for a book by title or author and delete it
void srchChng(); // Search for a book by title or author and change it
void displySort(); // Display library collection sorted by title or author


int main()
{
BookRecord *book; // create a pointer to BookRecord
fstream dataFile;
do
{
cout << "This program will simulate a Library Circulation System. \n";
cout << "Please choose an option below from 1 - 6 \n\n";
cout << "Options \n\n";
cout << "1. Enter and save a new book record \n";
cout << "2. Search for a book by title or author and display it \n";
cout << "3. Search for a book by title or author and delete it \n";
cout << "4. Search for a book by title or author and change it \n";
cout << "5. Display library collection sorted by title or author \n";
cout << "6. Quit program \n\n";
cin >> menuChoice;
cout << endl;

switch (menuChoice)
{
case 1:
recordArray(book);
break;

case 2:
cout << "2";
break;

case 3:
cout << "3";
break;

case 4:
cout << "4";
break;

case 5:
cout << "5";
break;

case 6:
cout << "Closing program \n\n";
break;

default: cout << "You did not enter a number from 1 - 6 \n\n";

}

} while(menuChoice> 0 && menuChoice < 7 && menuChoice!=6);

return 0;
}

///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
void recordArray(BookRecord *book);
{
bool optionHolder = false;

dataFile.open("Books.txt", ios::app); // Open File to store array
int index;
BookRecord *bkPtr = new BookRecord[index]; // Declare a pointer(bkPtr) to point to BookRecord and Dynamically Allocate BookRecord

for(int i = 0; i<index; i++)// if optionHolder = true than continue in not than exit
{
cout << "Enter Title \n";
cin >> bkPtr.title;
cout << "Enter Author \n";
cin >> bkPtr.author;
cout << "Enter ISBN \n";
cin >> bkPtr.ISBN;
cout << "Status of book: enter Y for in or N for out \n";
cin >> bkPtr.status;
cout << "To add another book enter Y or enter N to save and exit to Main Menu \n";
cin >> optionHolder;
}

if(!optionHolder)
{
dataFile.close();
cout << "Returning to Main Menu \n";
return;
}

}
Last edited on
my syntax error is right after void recordArray(BookRecord *book); in the function definition im starting to get turned around and lost so thought it was time to seek outside advice to get this function to work
Topic archived. No new replies allowed.