1: #include <stdio.h>
   2: #include <ctype.h>
   3: 
   4: char    *dit    = "dit";
   5: char    *daw    = "daw";
   6: 
   7: char    *digit[] = {
   8:     "-----",
   9:     ".----",
  10:     "..---",
  11:     "...--",
  12:     "....-",
  13:     ".....",
  14:     "-....",
  15:     "--...",
  16:     "---..",
  17:     "----.",
  18:     0
  19: };
  20: 
  21: char *alph[] = {
  22:     ".-",
  23:     "-...",
  24:     "-.-.",
  25:     "-..",
  26:     ".",
  27:     "..-.",
  28:     "--.",
  29:     "....",
  30:     "..",
  31:     ".---",
  32:     "-.-",
  33:     ".-..",
  34:     "--",
  35:     "-.",
  36:     "---",
  37:     ".--.",
  38:     "--.-",
  39:     ".-.",
  40:     "...",
  41:     "-",
  42:     "..-",
  43:     "...-",
  44:     ".--",
  45:     "-..-",
  46:     "-.--",
  47:     "--..",
  48:     0};
  49: 
  50: main() {
  51: 
  52:     register c;
  53: 
  54:     while ((c = getchar()) != EOF) {
  55:         if (isupper(c))
  56:             c = tolower(c);
  57:         if (isalpha(c))
  58:             print(alph[c-'a']);
  59:         else if (isdigit(c))
  60:             print(digit[c-'0']);
  61:         else if (c == ',')
  62:             print("--..--");
  63:         else if (c == '.')
  64:             print(".-.-.-");
  65:         else if (isspace(c))
  66:             printf(" ...\n");
  67:     }
  68: }
  69: 
  70: print(s) char *s; {
  71:     char *p;
  72:     for (p = s; *p; p++)
  73:         if (*p == '.')
  74:             printf(" %s", dit);
  75:         else if (*p == '-')
  76:             printf(" %s", daw);
  77:     printf(",\n");
  78: }

Defined functions

main defined in line 50; never used
print defined in line 70; used 4 times

Defined variables

alph defined in line 21; used 1 times
  • in line 58
daw defined in line 5; used 1 times
  • in line 76
digit defined in line 7; used 1 times
  • in line 60
dit defined in line 4; used 1 times
  • in line 74
Last modified: 1987-08-27
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2709
Valid CSS Valid XHTML 1.0 Strict