//编写一个程序将abc.txt文件的所有行加上行号后写到abc1.txt p286 todo CB
#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;
int main(){
fstream outfile,infile;
infile.open("abc.txt",ios::in);
if(!infile){
cout<<"abc.txt cannot open"<<endl;
abort();
}
outfile.open("abc1.txt",ios::out);
if(!outfile){
cout<<"abc1.txt cannot created";
abort();
}
char buf[80];
int i=0;
while(!infile.eof()){
infile.getline(buf,sizeof(buf));//将一行读到buf中 todo
outfile << i++ << ":"<<buf<<endl;
}
cout<<"abc.txt==>abc1.txt 转换成功"<<endl;
infile.close();
outfile.close();
return 0;
}