What i have to create is a program that establishes 2 structs with arrays of CD Albums and then search the arrays for album names and display the album name, Artist or group, songs and their track numbers.
My question is; [COLOR="red"]have i missed something in the code?[/COLOR], because it does not display the first album in the array when i do the search, it allows me to enter the name to search for but does not conduct the search, i would like to know what is wrong with the code.
thank you.
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<string>
using namespace std;
struct Song
{
string title;
int track;
};
struct Album
{
string albumName;
string artistName;
struct Song songList[4];
};
int main()
{
Album collection[5];
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;
string albumName;
cout<<"what album to search for? ";
cin>> albumName;
}
int search(Album collection[], string albumName)
{
int location;
for(int i = 0; i<5; i++);
{
if(location == -1)
return -1;
else
cout<<"Album name is:"<<collection[i].albumName<<" "<<collection[i].artistName<<"at"<<location<<".";