待解决close

关于close语句放在哪里,貌似会对结果产生影响

#include <iostream>
#include <fstream>
using namespace std;

int main(){
    ofstream fout("out.txt",ios::out|ios::binary);
    int x = 120;
    fout.write((const char *)(&x),sizeof(int));
    fout.close();
    ifstream fin("out.txt",ios::in|ios::binary);
    int y;
    fin.read((char *)&y,sizeof(int));
    fin.close();
    cout<<y<<endl;
//    fout.close();
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/fanmu/p/10618128.html
今日推荐