Hey everyone, I need help with my program it is an ipod simulator that goes like this:
/* FUNCTION - void initaPod
Initialize all the slots to blank and 0 size memory*/
void initaPod ();
/* FUNCTION - int addSong
attempts to add a new song to the aPod
returns a 0 if successful
returns -1 if not enough memory to add the song
returns -2 for any other error (such as a blank title or artist)*/
int addSong (string newTitle, string newArtist, int size);
/* FUNCTION - int removeSong
attempts to remove a song from the aPod
returns 0 if successful
returns -1 if nothing is removed */
int removeSong (string title);
/* FUNCTION - void clearMemory
clears all the songs from memory
*/void clearMemory();
/* FUNCTION - int getRemainingMemory
* returns the amount of memory left in your aPod that is available for use
*/ int getRemainingMemory();
/* FUNCTION - void showSongList
prints the current list of songs in order from first to last to standard output
format - slot #, Title, Artist, size in MB (one song per line)
print "Empty" for any slots that do not contain a song*/
void showSongList ();
/* FUNCTION - void shuffle
shuffles the songs into random order
will do nothing if there are less than two songs in the current list
*/
void shuffle ();
The problem is with my "showSongList" function because I have an input file that reads the Title(string), Artist(string), and Size(# of mb song is worth, int) and then displays the contents to the screen. I read the contents of the file into an array of structs then print it to the screen. I think the problem is when I try to call the function in "int main" or something about the arguments I try to pass to the array. Can someone help me? This is the code so far:
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
struct Songs{
string title;
string artist;
int size;
};
void showSongList(Songs title[],int &Num_Songs);
int main(){
const int Num_Songs = 8;
const int Memory_Size = 25;
string title;
string artist;
int size;
showSongList();
system("pause");
return 0;
} void showSongList(Songs title[],int &Num_Songs) {
ifstream inFile;
inFile.open("aPod.txt");
string title;
string artist;
int size;
inFile >> title;
while (inFile) {
inFile >> artist;
inFile >> size;
cout << title << artist << size <<endl;
title[Num_Songs].title = title;
title[Num_Songs].artist = artist;
title[Num_Songs].size = size;
Num_Songs++;
inFile >> title;
}
}