#include<iostream>
#include<string>
#include<fstream>>
using namespace std;
void readfile(){
//逐词读取
ifstream fp("data.txt");
string word;
while(fp>>word) {
cout<<word<<endl;
}
fp.close();
}
void readfile1() {
//逐行读取
ifstream fp("data.txt");
string str;
while(getline(fp , str)){
cout<<str<<endl;
}
fp.close();
}
void writefile(){
ofstream fp("data.txt");
for(int i = 0 ; i <10 ;i++){
fp<<"第" <<i<<"行\n";
}
fp.close();
}
int main(){
readfile();
readfile1();
writefile();
return 0;
}