english to morse code

i got an assignment from the class to do it from char not from strings i am getting an error so please debug this code

#include<iostream>
using namespace std;
char eng_to_mor(char[], char[], int);
char mor_to_eng(char[], char[], int);
int main()
{
char Eng[26] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
char Mor[26] = { '.-', '-...', '-.-.', '-..', '.', '..-.', '--.', '....', '..', '.---', '-.-', '.-..', '--', '-.', '---', '.--.', '--.-', '.-.', '...', '-', '..-', '...-', '.--', '-..-', '-.--', '--..' };
char will;
char text, morse;
int size = sizeof(text);
cout << "select 1 to encode english text in to morse code" << endl << "select 2 to convert morse code in to english";
cin >> will;
if (will==1)
{
cout << "type the text you want to encode in to morse code"<<endl;
cin >> text;
cout << "Text is" << endl << text;
cout << "Morse code is" << endl << eng_to_mor(Eng, Mor, size);

}
else if (will==2)
{
cout << "type the Morse code you want to translate" << endl;
cin >> morse;
cout << "Morse code is" << endl << morse << "English translation is " << endl << mor_to_eng(Eng, Mor, size);
}

return 0;

}
char eng_to_mor(char Eng[], char Mor[],int size)
{
for (int i = 0; i < size;i++)
{
Eng[i] = Mor[i];
return Mor[i];
}
}
char mor_to_eng(char Eng[],char Mor,int size)
{
for (int i = 0;i<size;i++)
{
Mor[i] = Eng[i];
return Mor[i];
}
}
i am getting an error

What error? Please be specific. Please post the full text of the error you're getting.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.

Line 8: You're trying to store multiple characters in a single character literal.

Line 44: You're trying to subscript a single character. The argument Mor is type char.
Last edited on
Topic archived. No new replies allowed.