I'm coming to the closing stages of my assignment (which is to create a media player) and all the functionality is there and now works fine.
The problem I have is that the media player contains an mp3 player and a cd player. When you launch the media player you select the player you want and can then swap between the two players.
HOWEVER: when swapping from the mp3 to the cd player, the application hangs. I've narrowed it down to hanging on this line:
The cd player works fine if opened first - assumably then, the Mp3 player is doing something that causes the cd player to hang...
ifstream CDList ("C:\\Documents and settings\\L&S\\Desktop\\c\\Assignment\\Backup\\CdList.txt");
This is my first real application in c++ and I'm struggling to understand why it happens. There are no error messages, no crashes - nothing. It just pauses... Even the cursor still blinks in the console...
If you need all the code i'll gladly post it but it is about 400lines long!
Do a pastebin of the code and post the URL here...
Is it possible that you have the file locked or something?
Ah, whatever, I think I need sleep (or lots of caffeine!)....
[/offtopic] Wow MacGyver slow down on the posts, I can't keep up :(
Ok, the CD player class is:
The Mp3 player class is:
There are about 8 other files - assume you don't want them as well?
The cdplayer and the mp3player use two different files - so assume the file isn't locked...??
Don't suppose anyone has any ideas at all?
I've been trying to complete it and work with it for several days now and still haven't got it working.
Its such a shame because this is the only bug left and my deadline is tomorrow.
If anyone does have any idea's - please let me have them! :-)
Thanks for all your help so far!
1. Fix the indentation, you're just making it much harder to follow the code.
2. This is needlessly compact.
Two closing braces next to each other, how can anyone determine the program flow without completely parsing the line to begin with?
3. Your constructors should initialise ALL the member variables of the class, not just some of them.
4. CD * Jukebox;
Where is the allocation for this array, with something like
JukeBox = new CD*[maxNumberOfCDs];
Experiment with small files, and a fixed array inside the class
CD * Jukebox;
You need to allocate space for your array before you do something like this
Jukebox[NoCD-1] = new CD(Title, Artist, NoTracks);
5. while (! myfile.eof() )
This is wrong, see the FAQ.
Just move the getline into the while, like so.
while ( getline (myfile,line) )
Thanks for your reply.
I'll plug my way through that lot and see if it gets rid of the bug!