Do not have the time to complete this due to a family emergency... I do not need the email text file. PM me for incentive
Write a program named email.cpp that opens and reads a text file and writes another text file. The purpose of the program is to extract email addresses embedded in the first (input) text file, and copy them to the second (output) text file. The application of the program is to make it easier to enter email addresses into an email message that is to be sent to a list of recipients, when those recipients are not already in a contacts list.
For example, the a website (www.sti.edu) has a Faculty and Staff Directory for each department (such as Computer Science). To send a single email message to everyone in the department, I have to copy/paste each email address individually from the directory into the "to", "cc", or "bcc" field of my email message. Using the new email.cpp program, I could save the web page containing the directory listing to a file, run the program, open its output file, and copy/paste the entire list from the file into the into the "to", "cc", or "bcc" field.
Here's another example -- WebAdvisor provides me with a roster of workers in each of my departments. The roster is a table with names, email addresses, 7-digit student IDs, etc. I would like to save that page to a file, run the email.cpp program, open its output file, and copy/paste the entire list from the file into the "to", "cc", or "bcc" field of a message to be sent to all workers in my department.
You can probably think of many other possible applications for such a program.
Here are the specifications for the program:
1. There are to be two console inputs to the program, as explained below. For each input, there is to be a default value, so that the user can simply press ENTER to accept any default. (That means
that string will be the best choice of data type for the console input for each option.)
2. Two console inputs are the names of the input and output files. The default filenames are to be fileContainingEmails.txt for the input file, and copyPasteMyEmails.txt for the output file. The default location for these files is the working folder of the program (so do not specify a drive or folder for the default filenames). The actual names and locations of the files can be any valid filename for the operating system being used, and any existing drive and folder.
3. It is okay for the user to select input and output names by the same name. If the user enters another name for the input file besides the default, then the default for the output file should change to be the same as that of the input file. So if the input and output filenames are the same, then the input file becomes replaced by the output file when the program is run.
4. The output file should be overwritten, and not appended to. No warning is necessary when overwriting an already-existing file.
5. Print each email to the output file, separated by a semicolon and a space. Include nothing before the first email message, and nothing after the last. Include nothing in the file besides email addresses and semicolon+space separators.
6. Do not allow duplicate email addresses to appear in the output file. Since you are supposed to preserve the case of email addresses, it is possible for an email address to appear more than once, cased differently -- like firstname.lastname@example.org and S@sti.edu. In this case, store one of them in its originally-cased form -- it does not matter which one you choose as long as it is one of them and not some other casing. (So you will have to store each email in a list as you process the input file, checking to see if it is already in the list before adding it. Then use the list to write the output file after the input file has been fully processed and closed).
7. Count the number of email addresses found as the input file is processed, and list each on a separate line of console output. At the end of the list of email addresses on the console, print the total number of email addresses found (not counting any duplicates). If the number of email addresses found is zero, do not write the output file. (That means, do not even open it.)
8. In case an email address is split between two or more lines in the input file, ignore it. Valid email addresses must appear fully within one line of the input file. Also, each line of the input file may contain more than one email address.
9. Include friendly, helpful labels on the console output. Instead of just printing the number of email addresses found, say something like "16 email addresses were found, and copied to the file output.txt". Or if none were found, say something like "Sorry, no email addresses were found in the file input.txt".
10. Include a message in the console output explaining to the user to open the output file and copy/paste its contents into the "to", "cc", or "bcc" field of any email message. But explain that it is best to use the "bcc" field so that everyone's email address does not appear in the message, to protect their privacy.
Do NOT use regular expressions -- they are a great way to solve this problem, but we did not cover them. Do NOT use char arrays for strings -- they are used in C for text strings, and we are using C++. Do NOT use pointers other than the ways we used them for dynamic arrays, array parameters, and links.
To test your program, get a faculty directory of your choosing from the website. Be sure to test your program with at least one other data source -- seach for one on the Internet, if you have to. You may share test input files with classmates, providing files to test each other's programs.