Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <iostream>
- #include <fstream>
- using namespace std;
- bool isValidEmialCharacter(char c) // Check each individual character to see if it is valid for an email address
- {
- bool result = false;
- if (c >='A' && c <='Z')
- result = true;
- else if (c >='a' && c <='z')
- result = true;
- else if (c >='0' && c <='9')
- result = true;
- else if ( c =='!' || c =='#' || c =='$' || c =='%' || c =='&' || c =='*' || c =='+' || c =='-' || c =='/' || c =='=' || c =='?' || c =='^' || c =='_' || c =='`' || c =='{' || c =='|' || c =='}' || c =='~' || c =='.')
- result = true;
- return result;
- }
- int main()
- {
- string input;
- string output;
- string emptycompare = ""; // Used to compare input with default names
- ifstream fin;
- cout << "Enter input filename [default: fileContainingEmails.txt]: ";
- getline(cin, input);
- if (input.compare(emptycompare) == 0) // If no input is supplied, the default file is opened
- {
- input = "fileContainingEmails.txt";
- fin.open(input.c_str());
- }
- else // If an input is supplied, that is opened instead
- fin.open(input.c_str());
- if (!fin.good()) throw "I/O error";
- cout << "Input file: " << input << endl;
- while (!fin.eof())
- {
- string lineFromFile;
- fin >> lineFromFile;
- fin.ignore(0, 10);
- for (int i = 0; i < lineFromFile.length(); i++)
- if (lineFromFile[i] == '@')
- cout << lineFromFile[i] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement