-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcppString.cpp
More file actions
56 lines (40 loc) · 1.02 KB
/
cppString.cpp
File metadata and controls
56 lines (40 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*****************************************************************************
Template prepared by K. Slott
11-22-2017
This program will read email addresses from email.dat and extract the username and department for each person.
email.dat (userName.dep@csusm.edu)
-------------
kslott.cs@csusm.edu
wu.cs@csusm.edu
puha.math@csusm.edu
price.phy@csusm.edu
harrison.eng@csusm.edu
******************************************************************************/
//James Bertel
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
string email;
ifstream fin;
int pos;
fin.open("email.dat");
if(!fin)
cout << "The input file doesn't exist" << endl;
else //the input file exists
{
fin >> email;
while(fin)
{
//extract the username and department and cout them.
pos = email.find(".");
pos++;
cout << email.substr(0, email.find(".")) << " at ";
cout << email.substr(pos, (email.find("@") - pos)) << endl;
fin >> email;
}
fin.close();
}
return 0;
}