I have a char*, named 'buffer', loaded from a file and processed. After writing it to another file I opened it with some hex editor and found that the output file is bigger than the buffer.
Looking for bugs I tried with ofile.put(buffer[0]) and ofile.put(buffer[length]), for example, and the resulting file is ok (filled with the same value). But with buffer[ i ] it has 56 extra bytes. The read function with length as second parameter has the same behaviour.