Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. #include <string>
  2. #include <iostream>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. bool isValidEmialCharacter(char c) // Check each individual character to see if it is valid for an email address
  8. {
  9. bool result = false;
  10.  
  11. if (c >='A' && c <='Z')
  12. result = true;
  13. else if (c >='a' && c <='z')
  14. result = true;
  15. else if (c >='0' && c <='9')
  16. result = true;
  17. else if ( c =='!' || c =='#' || c =='$' || c =='%' || c =='&' || c =='*' || c =='+' || c =='-' || c =='/' || c =='=' || c =='?' || c =='^' || c =='_' || c =='`' || c =='{' || c =='|' || c =='}' || c =='~' || c =='.')
  18. result = true;
  19.  
  20. return result;
  21. }
  22.  
  23. int main()
  24. {
  25. string input;
  26. string output;
  27. string emptycompare = ""; // Used to compare input with default names
  28. ifstream fin;
  29.  
  30. cout << "Enter input filename [default: fileContainingEmails.txt]: ";
  31. getline(cin, input);
  32. if (input.compare(emptycompare) == 0) // If no input is supplied, the default file is opened
  33. {
  34. input = "fileContainingEmails.txt";
  35. fin.open(input.c_str());
  36. }
  37. else // If an input is supplied, that is opened instead
  38. fin.open(input.c_str());
  39. if (!fin.good()) throw "I/O error";
  40.  
  41. cout << "Input file: " << input << endl;
  42.  
  43. while (!fin.eof())
  44. {
  45. string lineFromFile;
  46. fin >> lineFromFile;
  47. fin.ignore(0, 10);
  48. for (int i = 0; i < lineFromFile.length(); i++)
  49. if (lineFromFile[i] == '@')
  50. cout << lineFromFile[i] << endl;
  51. }
  52. return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement