#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main( )
{fstream inf,outf; //定义对象
inf.open("file.txt",ios::in); //打开文件读
outf.open("d:\\program files\\***\\***",ios::out); //打开文件写(默认为文本文件)
if(!inf) //创建文件成功 返回非0
{
cout<<"open file error.\n";
abort();//退出(包含在stdlib.h中)
}
char s[80];
cout<<"要输入的用户名和密码是:\n";
while(!inf.eof())//文件结束,eof()函数返回非0
{inf.getline(s,sizeof(s));//读一行
outf<<s<<"\n";
cout<<s<<endl;
}
inf.close();
outf.close();
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main( )
{fstream inf,outf; //定义对象
inf.open("file.txt",ios::in); //打开文件读
outf.open("d:\\program files\\***\\***",ios::out); //打开文件写(默认为文本文件)
if(!inf) //创建文件成功 返回非0
{
cout<<"open file error.\n";
abort();//退出(包含在stdlib.h中)
}
char s[80];
cout<<"要输入的用户名和密码是:\n";
while(!inf.eof())//文件结束,eof()函数返回非0
{inf.getline(s,sizeof(s));//读一行
outf<<s<<"\n";
cout<<s<<endl;
}
inf.close();
outf.close();
return 0;
}