Bugs!

This is a discussion on Bugs! within the C++ Programming forums, part of the General Programming Boards category; Afternoon all, I'm coming to the closing stages of my assignment (which is to create a media player) and all ...

  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    12

    Bugs!

    Afternoon all,

    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:
    Code:
      ifstream CDList ("C:\\Documents and settings\\L&S\\Desktop\\c\\Assignment\\Backup\\CdList.txt");
    The cd player works fine if opened first - assumably then, the Mp3 player is doing something that causes the cd player to hang...

    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!

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Do a pastebin of the code and post the URL here...

  3. #3
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Is it possible that you have the file locked or something?

    Ah, whatever, I think I need sleep (or lots of caffeine!)....

  4. #4
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    [/offtopic] Wow MacGyver slow down on the posts, I can't keep up

  5. #5
    Registered User
    Join Date
    May 2007
    Posts
    12
    Ok, the CD player class is:
    http://www.lsweb.co.uk/OnlineHouseMo...s/cdplayer.txt

    The Mp3 player class is:
    http://www.lsweb.co.uk/OnlineHouseMo.../mp3player.txt

    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...??

  6. #6
    Registered User
    Join Date
    May 2007
    Posts
    12

    Question

    Morning all,

    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!

    Leigh

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,553
    Some comments.

    1. Fix the indentation, you're just making it much harder to follow the code.

    2. This is needlessly compact.
    Code:
    {if(CurrentPos <5){CurrentPos=0;PrevTrack();}else{CurrentPos-=5;}}
    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[20];

    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) )
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  8. #8
    Registered User
    Join Date
    May 2007
    Posts
    12

    :-/

    Thanks for your reply.

    I'll plug my way through that lot and see if it gets rid of the bug!

    Thanks again

    Leigh

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. relation between bugs and compilation time
    By KIBO in forum Tech Board
    Replies: 10
    Last Post: 01-29-2009, 12:29 PM
  2. Bugs in Program Question
    By racerday182 in forum C++ Programming
    Replies: 14
    Last Post: 12-05-2008, 09:30 AM
  3. what are the bugs in this code..please help me.
    By me001 in forum C Programming
    Replies: 12
    Last Post: 09-23-2008, 10:52 AM
  4. Need help finding bugs
    By Shakti in forum Game Programming
    Replies: 16
    Last Post: 02-13-2005, 12:42 AM
  5. Need help fixing bugs in data parsing program
    By daluu in forum C Programming
    Replies: 8
    Last Post: 03-27-2003, 05:02 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21