Works for me on cygwin, which compiler are you using?
Code:
#include <fstream>
#include <iostream>
using namespace std;
int main ( ) {
fstream f;
f.open( "foo.bin", ios::in | ios:: out | ios::binary | ios::trunc );
char msg[10] = "woohoo";
f.write( msg, 10 );
char test[10];
f.seekg( 0, ios::beg );
f.read( test, 10 );
cout << test << endl;
f.close();
}
> f.write((unsigned char*)screen0[j][i], sizeof(int));
1. It should be &screen0[j][i]
2. You could write out the whole array in one go with
f.write( (unsigned char*)screen0, sizeof screen0 );