//读写2进制流文件 #include <fstream.h> #include <iostream.h> #include <stdlib.h> void main() { ofstream f1("wr1.dat"); if(!f1) { cerr<<"wr1.dat file not open!"<<endl; exit(1); } //f1.seekp(beg); for(int i=0;i<21;i++) f1<<i<<" "; f1.close(); ifstream f2("wr1.dat",ios::in|ios::nocreate); if(!f1) { cerr<<"wr1.dat file not open!"<<endl; exit(1); } int x; while(f2>>x) cout<<x<<' '; cout<<endl; f2.close(); } 相关文章: 2021-09-16 2021-10-06 2021-12-01 2021-11-02 2022-02-16 2022-02-04 2021-07-21