我必须编写一个程序,该程序将从文件中提取电子邮件地址并将其放入另一个文件中。我不知道如何让程序将信息放入其他文件中。另外,我是否必须创建第二个文件,就像我必须创建第一个文件一样?以下是我迄今为止:如何将提取的数据写入outfile。程序旨在从文件中提取电子邮件地址C++
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
char chr;
int main()
{
string mail;
ifstream inFile; //this is the file that we will get the information from
ofstream outfile; // this is the file that the data will be saved in
inFile.open("mail.dat"); // this will open the file with the original informations
outfile.open("addresses.dat"); // this will open the file where the output will be
while (inFile)
{
cin>>mail;
mail.find('@')!=string::npos; //this finds the email addresses
}
inFile.close(); // this will close the file when we are done with it
outfile.close();
cin>>chr;
return 0;
}