forked from DanielBillette/SoftwareProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrototype code
More file actions
74 lines (66 loc) · 1.17 KB
/
Prototype code
File metadata and controls
74 lines (66 loc) · 1.17 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void PrintEmails();
void SelectTeachers();
string Teachers[100];
int main ()
{
string line;
int count = 0;
ifstream myfile ("Teachers.txt");
if (myfile.is_open())
{
while ( getline (myfile,line) )
{
Teachers[count] = line;
count++;
}
myfile.close();
}
else cout << "Unable to open file";
PrintEmails();
SelectTeachers();
}
void PrintEmails()
{
int count = 1;
while(Teachers[count - 1] != "\0")
{
cout << count << ": " << Teachers[count - 1];
if(count % 3 == 0)
{
cout << endl;
}
else
{
cout << "\t";
}
count++;
}
}
void SelectTeachers()
{
int UserInput = 1;
ofstream myfile ("Recipients.txt");
while(UserInput != 0)
{
cout << "\n(0 to finish) Choose a recipient: ";
cin >> UserInput;
if (myfile.is_open())
{
if(UserInput == 0)
{
cout << "\n\t[\tRecipients saved to file 'Recipients.txt'\t]\t\n\n";
}
else
{
myfile << Teachers[UserInput - 1] << endl;
cout << "\n\t[\t" << Teachers[UserInput - 1] << " added to recipients list" << "\t]\t" << endl;
}
}
else cout << "Unable to open file";
}
myfile.close();
}