目前,在 32 位机器上,我将二进制数据写入文件,如下所示:
outbin.write( reinterpret_cast <const char *> ( &key_session ), sizeof( unsigned int ) );
outbin.write( reinterpret_cast <const char *> ( &last_access_time ), sizeof( time_t ) );
outbin.write( reinterpret_cast <const char *> ( &sizet ), sizeof( size_t ) );
outbin.write( reinterpret_cast <const char *> ( &ddd), sizeof( double ) );
outbin.write( reinterpret_cast <const char *> ( &fff), sizeof( float ) );
如何写入数据以使其可移植并确保数据将在任何机器(64 位)上加载?(可能会在机器上将操作系统更改为 64 位或将数据复制到其他机器时)