I want to write data to a file one byte at a time. I am having a problem that for some reason the write function is writing 2 bytes instead of one. Here is the code.
int begin, end, dummy;
begin = ftellp(); //get the current position
bin3ds2.write ( &ch, 1 );
end = ftellp( file ); //get the current position
if( end - begin != 1 ) {
++dummy //a breakpoint is here
}
If it works correctly end - begin should always be one, but sometimes it's two. I think that something else in my code might be causing this to happen, but I don't know what. Can anyone help me with this. I have been strugling with this for a while, and I can't seem to solve it. I think I need someone else to look over my code. Thanks.