// Example 2.1
// This version of the program uses only one array in which to store
// all book details.  The program processes details of only one book.
// Note the use of #include <string> with strings and getline() to read a string.
 

#include <iostream>
#include <string>

const int MAX_ELEMENTS = 200;

int main()
{
    // define an array of string
    string Books[MAX_ELEMENTS];

    // define a variable with which to index the array
    int j=0;

 

    cout << "Enter Book Details"<<endl;
    cout << "Enter title"<<endl;
    getline(cin,Books[j]);j++;         // read the title details into the array and increment the index

    cout << "Enter author"<<endl;
    getline(cin,Books[j]);j++;             // read the author details into the array and increment the index

    cout << "Enter publisher"<<endl;
    getline(cin,Books[j]);                 // read the publisher details into the array

    j=0; // reinitialise the index to the start of the array for printing

    cout<<"Title: "<<Books[j]<<endl;j++;         // print the title details and increment the index
    cout<<"Author: "<<Books[j]<<endl;j++;     // print author details and increment the index
    cout<<"Publisher: "<<Books[j]<<endl;       // print the publisher details
}