#include <iostream>
const int MAX_ELEMENTS = 200;
int main()
{
char title[MAX_ELEMENTS];
char author[MAX_ELEMENTS];
char publisher[MAX_ELEMENTS];
char ch;
int i;
//Initialise the
arrays to contain spaces
for(i=0; i<
MAX_ELEMENTS; i++)
{
title[i] = ' ';
author[i] = ' ';
publisher[i]= ' ';
}
// Request Input
of title details.
cout <<endl<<
"Enter title"<<endl;
cout << "Enter
the / character when finished and press return"<<endl;
i=0;
cin >> ch; title[i]
= ch;i++;
while (ch != '/')
// read characters until the '/' key is read
{
cin >>ch; // read a character
title[i] = ch; // place the character in the array
position title[i]
i++;
// increment i
}
// Request Input
of author details.
// This version
of the loop for author and publisher
// works best as
it allows an empty name to be entered
// i.e., just the
'/' character to indicate the end of the name.
cout << "Enter
author"<<endl;
cout << "Enter
the / character when finished and press return"<<endl;
i=0;
cin >> author[i];
// read a character into array position author[i]
while (author[i]
!= '/') // read until the '/' character is read
{
i++;
// increment i
cin >>author[i]; // read
the next character
}
// Request Input
of publisher details.
cout << "Enter
publisher"<<endl;
cout << "Enter
the / character when finished and press return"<<endl;
i=-1;
// initialise i to -1
do{
i++; // increment i
cin >> publisher[i]; //
read a character into array position publisher[i]
}
while (publisher[i] != '/');
// read until the '/' character is read
// Output of title
details.
i=0;
cout << title[i];i++;
while (title[i]
!= '/')
{
cout << title[i];
i++;
}
cout << endl;
// Output of author
details.
i=0;
while (author[i]
!= '/')
{
cout << author[i];
i++;
}
cout << endl;
// Output of publisher
details.
i=0;
while (publisher[i]
!= '/')
{
cout << publisher[i];
i++;
}
cout << endl;
}