C++ .blend file exporter

Hey guys. I’m made a start on a c++ .blend import library to use in C++ applications.

I’ve been studying the file format as explained here: http://www.atmind.nl/blender/mystery_ot_blend.html

I’ve managed to retrieve the file header information. I’m stuck on the the file-blocks though. I’m managing to get the first file-block ‘code’, but I’m struggling to get the file block size.

Anybody know where I might be going wrong with my code?

//Read file block code
    char* buffer = new char[5];
    buffer[4] = '\0';
    inFile.seekg(iBufferStart, std::ios_base::beg);
    inFile.read(buffer, 4);
    std::cout << "Code: " << buffer << "
    delete buffer;

    //Read file block data size
    char* intBuffer = new char[5];
    buffer[4] = '\0';
    inFile.seekg(iBufferStart + 4, std::ios_base::beg);
    inFile.read(intBuffer, 4);
    std::cout << "Size: " << intBuffer << "
    delete intBuffer;

intBuffer contains (well, possibly, it really depends on the offset of your input stream but if you can read the code it should be ok) the four bytes of a 32 bit integer in some endianness.
If you print it like it was a string of character, you get the impression of having the wrong values. The values are fine, it’s the interpretation that is wrong. Use the four bytes int intBuffer to rebuild the 32 integer and read that as the size.

You can see how Assimp library read .blend files here: https://github.com/assimp/assimp/blob/master/code/BlenderLoader.cpp