Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing a MIDI file loader. Everything is going fine until at some track I get a failbit exception while trying to read from file. I can't figure out why, I've checked the file size and it's ok too.

Upon checking "errno" and it returns "0".

Any ideas? Thanks.

The snippet follows:<char*>(&, sizeof(MidiHeader));

mTracks = new MidiTrack[mHeader.nTracks];
for (uint i = 0; i < mHeader.nTracks; ++i)
    // this read fails on 6th i. I've checked hexadecimal file and it's
    // ok so far.<char*>(&mTracks[i].id), sizeof(uint));
    if (
        std::cerr << errno << std::endl;
    massert(mTracks[i].id == 0x6B72544D);<char*>(&mTracks[i].size), sizeof(uint));
    mTracks[i].size = swapBytes(mTracks[i].size);

    mTracks[i].data = new char[mTracks[i].size];[i].data, mTracks[i].size * sizeof(char));

    totalBytesRead += 8 + mTracks[i].size;
    massert(totalBytesRead <= fileSize);
share|improve this question

closed as off-topic by Josh Petrie Jan 2 '14 at 18:00

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Programming questions that aren't specific to game development are off-topic here, but can be asked on Stack Overflow. A good rule of thumb is to ask yourself "would a professional game developer give me a better/different/more specific answer to this question than other programmers?"" – Josh Petrie
If this question can be reworded to fit the rules in the help center, please edit the question.

Is this gamedev related? – nathan Sep 28 '12 at 16:07
@nathan As far as I'm concerned games do have sound processing, don't they? and yes, this is for a rhythm game. They usually load guitar and vocal charts as midis. – Phil Lira Sep 28 '12 at 16:25
For programming questions, see the faq. Specifically, programming questions are on topic if a game programmer would give a better answer than a general programmer. This just seems to be a file loading issue and not game specific. – Tetrad Sep 28 '12 at 20:26

Browse other questions tagged or ask your own question.