Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct
{
char morse[6];
char letter;
}morsecode;
int main(){
morsecode trans[36]={
{".-", 65}, {"-...", 66}, {"-.-.", 67}, {"-..", 68}, {".", 69}, {"..-.", 70},
{"--.", 71}, {"....", 72}, {"..", 73}, {".---", 74}, {"-.-", 75}, {".-..", 76},
{"--", 77}, {"-.", 78}, {"---", 79}, {".--.", 80}, {"--.-", 81}, {".-.", 82},
{"...", 83}, {"-", 84}, {"..-", 85}, {"...-", 86}, {".--", 87}, {"-..-", 88},
{"-.--", 89}, {"--..", 90}, {"-----", 48}, {".----", 49}, {"..---", 50},
{"...--", 51}, {"....-", 52}, {".....", 53}, {"-....", 54}, {"--...", 55},
{"---..", 56}, {"----.", 57}
};
char phrase[34] = {"DUDE WHERES THE 1978 GOGGO MOBILE"};
int search, index;
for(index = 0; index <= 33; index++){
for(search = 0; search <= 35; search++){
if(trans[search].letter == phrase[index]){
printf("%s ", trans[search].morse); }else if(phrase[index] == ' '){
printf(" ");
}else{
printf("\nError Char not found!!!\n");
}
}
}
return 0;
}