Get rid of that awful switch block and use a lookup table:
char* letters[] = { ".-", "-...", "-.-.", "-..", ".",
"..-.", "--.", "....", "..", ".---",
"-.-", ".-..", "--", "-.", "---",
".--.", "--.-", ".-.", "...", "-",
"..-", "...-", ".--", "-..-", "-.--", "--.." };
index = chrin - 'a';
return letters[index];
You just need to add the code for numbers, and a check for an illegal character.