-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMail_filter.cpp
46 lines (43 loc) · 1.06 KB
/
Mail_filter.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
string st;
string notallowed="remaining.txt";
char sourcefile[50];
cout << "Enter Source File with Extension: ";
ifstream in;
ofstream out;
gets(sourcefile);
in.open(sourcefile);
string mail;
if (!in || sourcefile==notallowed)
{
cout << "Error in Opening Source File,Try again or Select another...!!!";
exit(1);
}
cout<<"Enter Domain (eg. @gmail.com,.edu):\n";
cin>>mail;
string extension=mail+".txt";
cout << "Wait...!!!"<<endl;
while (in.eof() == 0)
{
getline(in, st);
if (st.find(mail) > 0 && st.find(mail) < 50)
{
// cout << st << endl;
ofstream out(extension, ios::app);
out << st << endl;
}
else
{
ofstream out("remaining.txt", ios::app);
out << st << endl;
// cout << "null" << endl;
}
}
cout << "Done";
return 0;
}