I'm trying to convert Morse code to the alphabet and numbers. So I have an encrypted message that I got from a file. I've created a hash table of morse code and alphabet. I created a function that will change one single piece of morse code at a time to the alphabet. What I'm having trouble with is decrypting a whole string of morse code. Specifically with my findMorse function I'm not sure which parameters I should be using on the binary that I converted to Morse code. Here's all of my code:
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <fstream>
#include<stdio.h>
#include<stdlib.h>
#include <stdio.h>
#include <string.h>
using namespace std;
class bitsetHashtable
{
private:
static const int tableSize = 60;
struct item
{
string morseCo;
string Alpha;
item* next;
};
item* HashTable[tableSize];
public:
bitsetHashtable();
int Hash(string key);
void AddItem(string morseCo, string Alpha);
int NumberOfItemsInIndex(int index);
void PrintTable();
void findMorse(string morseCo);
void convertToArray(string alpha);
};
bitsetHashtable::bitsetHashtable()
{
for (int i = 0; i < tableSize; i++)
{
HashTable[i] = new item;
HashTable[i]->morseCo = "empty";
HashTable[i]->Alpha = "empty";
HashTable[i]->next = NULL;
}
}
void bitsetHashtable::AddItem(string morseCo, string Alpha)
{
int index = Hash(morseCo);
What I'm having trouble with is decrypting a whole string of morse code
It depends on the input format. If you separate each morse token by a space you could read it into a string with getline and split it with a stringstream.
1 2 3 4 5 6
string input;
getline(cin, input);
istringstream iss(input);
string token;
while (iss >> token)
// convert token into text
Why don't you use a map<string, string> ?
It would make life soo much easier.