文件读入和写入

#include <bits/stdc++.h>
#include <fstream>
using namespace std;
int main(int argc, char** argv) {
    char data[100];
    ofstream a;
    a.open("hehe.txt");
    cout<<"请写下你想对你的班主任的话,呵呵"; 
    cin>>data;
    a<<data<<endl;
    a.close();
    ifstream b;
    b.open("haha.txt");
    cout<<"现在我来告诉你!";
    b>>data;
    cout<<endl;
    cout<<data<<endl;
    b.close();
    return 0;
}

 

posted @ 2023-11-03 20:11  fushuxuan1  阅读(11)  评论(0)    收藏  举报