1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#include <iostream>
#include <cstring>
using namespace std;
bool findTitlePrice(string allTitles[], double allPrices[],
int totalRec, string title, double & price);
const int MAXSIZE=300;
int main()
{
string x;
string titles[]={"Book 1","Book 2"};
double Prices[]={78.5,66.0};
int totalRecords = 2;
string title = "book";
double price = 0.0;
findTitlePrice(titles,Prices,2,title,price);
//else {cout << "We probably dont have that book";}
system("pause");
return 0;
}
// function definition
bool findTitlePrice(string AllTitles[], double AllPrices[],
int TotalRec, string Title, double & Price)
{
string title;
cout << endl;
cout<< "Please enter title of the book you are searching for : ";
cin >> title;
for(int i =0; i < TotalRec; ++i)
{
if (title == AllTitles[i])
return true;
}
}//listRecords.cpp
| |