C ++のバイナリファイルのファイル操作 - 書き込みファイル

書式#include <iostreamの> 
の#include <fstreamの> 
の#include < 文字列 >
 使用して 名前空間はstdを、
クラス人{
 パブリック文字名[ 64 ]。
    int型の年齢; 
}。
ボイド試験(){ 
    ofstreamのをOFS。
    ofs.open(" person.txt "、イオス:: アウト | イオス::バイナリ)。
    人物P = { " 张三"18 }。
    ofs.write((のconst  のchar *)&P、sizeof (人)); 
    ofs.close(); 
} 
int型のmain(){ 
    テスト(); 
    システム(一時停止)。
    リターン 0 ; 
}

おすすめ

転載: www.cnblogs.com/xiximayou/p/12103094.html