我必須編寫一個程序,該程序將從文件中提取電子郵件地址並將其放入另一個文件中。我不知道如何讓程序將信息放入其他文件中。另外,我是否必須創建第二個文件,就像我必須創建第一個文件一樣?以下是我迄今爲止:如何將提取的數據寫入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;
}