Question

Project 6-1: Email Creator Create a program that reads a file and creates a series of emails Console Email Creator jbutler@gm

In C++ please!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

If you have any doubts, please give me comment...

#include<iostream>

#include<fstream>

#include<sstream>

#include<cctype>

#include<string>

using namespace std;

string toLower(const string &str);

int main(){

    ifstream in;

    in.open("email_template.txt");

    if(in.fail()){

        cout<<"Unable to open email_template.txt"<<endl;

        return -1;

    }

    string line, fname, uname, email;

    string temp_copy, temp="";

    int pos;

    while(!in.eof()){

        getline(in, line);

        temp += line+"\n";

    }

    in.close();

    in.open("email_list.txt");

    if(in.fail()){

        cout<<"Unable to open email_list.txt"<<endl;

        return -1;

    }

    cout<<"Email Creator"<<endl<<endl;

    while(!in.eof()){

        getline(in, line);

        istringstream ss(line);

        getline(ss, fname, '\\');

        getline(ss, uname, '\\');

        getline(ss, email, '\\');

        fname = toLower(fname);

        fname[0] = toupper(fname[0]);

        email = toLower(email);

        temp_copy = temp;

        while((pos=temp_copy.find("{email}"))!=string::npos){

            temp_copy.replace(pos, 7, email);

        }

        while((pos=temp_copy.find("{first_name}"))!=string::npos){

            temp_copy.replace(pos, 12, fname);

        }

        cout<<"========================================================"<<endl;

        cout<<temp_copy;

    }

    in.close();

    return 0;

}

string toLower(const string &str){

    string result = "";

    for(int i=0; i<str.size(); i++){

        result += tolower(str[i]);

    }

    return result;

}

nagarajuanagaraju-Vostro-3550:15092019$ g++ email.cpp nagarajuanagaraju-Vostro-3550:15092019$ ./a.out Email Creator =========

Add a comment
Know the answer?
Add Answer to:
In C++ please! Project 6-1: Email Creator Create a program that reads a file and creates...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT