Advertisement
Guest User

Untitled

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