#include <iostream>
#include <fstream>
#include <string>
using namespace std;
#define inFile "inDate.txt"
#define outFile "outFile.txt"
void processFile(ifstream &ins, ofstream &outs);//文件操作函数
int main()
{
ifstream ins;
ofstream outs;
//定义输入输出文件流对象
ins.open(inFile);
if (ins.fail())
{
cerr << "Cannot open File " << inFile << endl;
exit(0);
}
outs.open(outFile);
if (outs.fail())
{
cerr << "Cannot open File " << outFile << endl;
exit(0);
}
porcessFile(ins, outs); //调用函数
ins.close();
outs.close();
return 0;
}
void porcessFile(ifstream &ins, ofstream &outs)
{
int cout = 0;
string line; //定义字符串
getline(ins, line);
count++;
while (!ins.eof())
{
outs << "count" << "
" << line << endl;
getline(ins, line);
count++;
}
}
文件你自己弄一个吧.
程序大概是这样。