-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
42 lines (36 loc) · 931 Bytes
/
main.cpp
File metadata and controls
42 lines (36 loc) · 931 Bytes
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
#include "bst.h"
#include <fstream>
using namespace std;
int main(void)
{
char oneC = '\0';
string line;
BST example=new BST(true);
fstream convert;
convert.open("Convert.txt", ios::in);
cout << "Converting characters of convert.txt into Morse Code " << endl;
if (convert.is_open()) // if Convert.txt opened successfully
{
while (getline(convert, line)) // reads in the whole line
{
for (int i = 0; line[i] != NULL; ++i) // and then finds each character in said line
{
oneC = line[i];
if (oneC != ' ') // if it is not a space, find the letter in the BST
{
oneC = toupper(oneC);
cout << example.lookUp(oneC) << " ";
}
else // if it is a space, make it three spaces not just one
{
cout << " ";
}
}
cout << endl; // if there is more than one line, they will be separated by new lines
}
}
else
{
cout << "Convert.txt failed to open!" << endl;
}
}