文件流

#include <iostream>
#include <fstream>
using namespace std;
int main(){
    char data[100];
    ofstream out;
    string name;
    
    string _data;
    ifstream outfile;
    outfile.open("老师.txt");
    outfile>>_data;
    cout<<_data<<endl;
    
    for(int i = 1;i<=10;i++){
        name = "祝福老师"+to_string(i)+".txt";
        out.open(name);
        cout<<"你想对老师说什么?"<<endl;
        cin.getline(data,100);
        out<<data<<endl;
        out.close();
    }
    return 0;
}

 

posted @ 2023-11-03 20:06  王一行(小号)  阅读(5)  评论(0编辑  收藏  举报