I have been making a program that converts Letters, Numbers and Punctuations into morse code.
With the letters and numbers its working as I want it.
But with the punctuations I cant make it work properly. I was hoping someone could take a look at my code and help me.
#include <iostream>
#include <cstring>
#include <sstream>
using namespace std;
char ch;
string morseWord = "";
for(unsigned int i=0; i < word.length(); i++)
{
if(isalpha(word[i]))
{
ch ;
}
}
return morseWord;
}
char ch;
string morseWord = "";
for(unsigned int i=0; i < word.length(); i++)
{
if(isdigit(word[i]))
{
ch = word[i];
ch = toupper(ch);
morseWord += morseCode[ch - '0'];
morseWord += " ";
string morseWord = "";
for(unsigned int i=0; i < word.length(); i++)
{
if(ispunct(word[i]))
{
ch = word[i];
ch = toupper(ch);
morseWord += morseCode[ch - '.'];
morseWord += " ";
}
}
return morseWord;
}
int main()
{
stringstream ss;
string sentence;
string word = "";
code: " << endl;
while(ss >> ToMorse(word) << endl;
cout << PunctuationToMorse(word) << endl;
}