#include #include #include // gets #include // strcat #define MAXLENGTH 80 char *encode(const char *s); int main(void) { char word[MAXLENGTH]; char *morse = NULL; printf("Sözcüğü yazınız: "); scanf("%s", word); morse = encode(word); printf("Morse karşılığı: %s\n",morse); free(morse); system("pause"); return 0; } char *encode(const char *s) { static char encoding[][5] = { ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.." }; char *morse = new char[MAXLENGTH]; int i; morse[0] = '\0'; for (i = 0; s[i] != '\0'; i++) { strcat(morse, encoding[s[i] - 'a']); strcat(morse, " "); } return morse; }