Created
June 6, 2014 19:24
-
-
Save h2rashee/b29e9feda6e295b6571d to your computer and use it in GitHub Desktop.
Processes e-mail lists and extracts e-mails from: "Name" (Email); ...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
vector<string> emails; | |
void printVector() | |
{ | |
for(vector<string>::iterator it = emails.begin(); it != emails.end(); it++) | |
{ | |
cout << *it << "; "; | |
} | |
cout << endl; | |
} | |
int main() | |
{ | |
string input; | |
getline(cin, input); | |
int pos = 0; | |
while(input.find_first_of("(",pos) != string::npos) | |
{ | |
string em; | |
int start = input.find_first_of("(",pos) + 1; | |
int end = input.find_first_of(")",pos); | |
em = input.substr(start, end-start); | |
emails.push_back(em); | |
pos = end + 1; | |
if(input.length() < pos) | |
{ | |
break; | |
} | |
} | |
printVector(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment