I want the program to have the user select either Y or N to display the list of albums in the array, if the user entered Y to display the list of albums then have the user enter a name for an album from the list to search the array for artist name, songs and Track numbers for that album. The code i have now, does not allow the operator to enter an album name to search the array.

Thank you for you assistance.

Here is the code i have.

#include<iostream>					
#include<iomanip>					
#include<cstdlib>					
#include<string>					

using namespace std;

struct Song							
{
	string title;
	int track;
};

struct Album						
{
	string albumName;
	string artistName;
	Song songList[4];
};

void asearch(Album collection[], int size, string albumName);

void search(Album collection[], int size, string albumName);

int main()
{
	Album collection[4];						

	collection[0].albumName = "Private Investigations";
	collection[0].artistName = "Dire Straits";
	collection[0].songList[0].title = "Sultans of Swing";
	collection[0].songList[0].track = 2;
	collection[0].songList[1].title = "Romeo and Juliet";
	collection[0].songList[1].track = 4;
	collection[0].songList[2].title = "Money for Nothing";
	collection[0].songList[2].track = 9;
	collection[0].songList[3].title = "Walk of Life";
	collection[0].songList[3].track = 10;
	collection[1].albumName = "The Millennium Collection";
	collection[1].artistName = "The Who ";
	collection[1].songList[0].title = "My Generation";
	collection[1].songList[0].track = 1;
	collection[1].songList[1].title = "Pinball Wizard";
	collection[1].songList[1].track = 2;
	collection[1].songList[2].title = "Who are You";
	collection[1].songList[2].track = 3;
	collection[1].songList[3].title = "Squeeze Box";
	collection[1].songList[3].track = 4;
	collection[2].albumName = "Moving Pictures";
	collection[2].artistName = "RUSH ";
	collection[2].songList[0].title = "Tom Sawyer";
	collection[2].songList[0].track = 1;
	collection[2].songList[1].title = "Rad Barchetta";
	collection[2].songList[1].track = 2;
	collection[2].songList[2].title = "YYZ";
	collection[2].songList[2].track = 3;
	collection[2].songList[3].title = "Limelight";
	collection[2].songList[3].track = 4;
	collection[3].albumName = "The Best of 3 Dog Night";
	collection[3].artistName = "3 Dog Night ";
	collection[3].songList[0].title = "Joy to the World";
	collection[3].songList[0].track = 1;
	collection[3].songList[1].title = "Easy to be Hard";
	collection[3].songList[1].track = 2;
	collection[3].songList[2].title = "Family of Man";
	collection[3].songList[2].track = 3;
	collection[3].songList[3].title = "Sure as i'm sitting here";
	collection[3].songList[3].track = 4;

	string albumName;
	bool choice;
	
	cout<<"Display the list of the albums? Y or N"<<'\n';
	cin>>choice;

	asearch (collection, 4, albumName);
	
	cout<<"Enter the album name: "<<'\n';
	getline(cin, albumName);
	

	search (collection, 4, albumName);		
}//end main

void asearch(Album collection[], int size, string albumName)
{
	bool Y = true;
	bool N = false;
	if(Y)
		for (int i = 0; i<size; i++)
		{
			cout<<collection[i].albumName<<"."<<'\n';
		}
	else if(N)
		cout<<"Not displaying albums in Database!!!"<<'\n';
}//end search

void search(Album collection[], int size, string albumName) 
{
	bool found = false;						
	for(int i = 0; i < size; i++)			
	{
		if(collection[i].albumName == albumName)	
		{	
			if(!found)						
				 found = true;				
            cout<<"by "<<collection[i].artistName<<'\n';	
			for(int sl = 0; sl < size; sl++)	
			{
				cout<<'\t'<<collection[i].songList[sl].title<<" on Track # "
					<<collection[i].songList[sl].track<<"."<<'\n';	
			}
		}
	}
	if(!found)								
		cout << "No such album found!!!"<<'\n';	
}//end search

Since you want the user to enter either 'Y' or 'N' it must be entered as a string, not a bool. You should redeclare choice as a std::string because data type bool only accepts a 0 or 1.

And don't create multiple threads for the same question.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.