fstreamを使用する際、バイナリモードでファイルを開く時の注意

Unix系では何もせずともバイナリモード。
Windowsではsetmode(filebuf::binary)する。
Classic Mac(CodeWarrior)ではオープン時にios::binaryを指定する。

----*----*----*----*----*----*----*----*----
#ifdef	__MWERKS__
    ifstream fin(fname, ios::binary);
#else
    ifstream fin(fname);
#endif

    if( fin ) {
#ifdef	_WIN32
        fin.setmode(filebuf::binary);
#endif
          :
          :
          :
    }
----*----*----*----*----*----*----*----*----

ofstreamでも一緒。