Question: C++ please Write a program whose input is the name of a file that contains valid email addresses, one per line. The program then parses
C++ please
Write a program whose input is the name of a file that contains valid email addresses, one per line. The program then parses and outputs each domain and username. Example: suppose the file "input1.txt" contains
pooja@piazza.com drago12@uic.edu javiar_g@hotmail.com
If the program is given the filename "input1.txt", the program outputs the following to the console:
piazza.com, pooja uic.edu, drago12 hotmail.com, javiar_g
Your solution should use the parseEmailAddress function written in the previous exercise. If the input file does not exist, output "**file not found", otherwise process the contents of the input file; assume the input file contains one or more valid email addresses.
main.cpp
// // HW #02-3: program to parse a file containing email addresses, outputting the // domains and usernames. //
#include
using namespace std;
// // parseEmailAddress: // // parses email address into usernam and domain, which are // returned via reference paramters. // void parseEmailAddress(string email, string& username, string& domain) { // // TODO: // username = ""; domain =""; return; }
int main() { string filename; cout << "Please enter a filename> "; cin >> filename; cout << endl; // // TODO: //
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
