有人可以解释此功能代码的逻辑吗?

有人可以向我解释此功能代码的逻辑吗?该功能的目的是解码莫尔斯电文。

 typedef struct{
        char letters[5]; /* store the letters/numbers. Get it as a string but only use the first */
        char lettersMorse[8];/* store the respective symbols morse of the letters/numbers */
    }alphabet;
    alphabet l[37];

字母/数字及其各自的莫尔斯电符号被存储在与上述相同的结构中

char morseToChar(char *string) {
    for (int i=1; i<37; i++) {
        if (strcmp(l[i].lettersMorse, string) == 0) {
            return l[i].letters[0];
        }
    }
}

void decode(char *string) {
    int current = 0, spaces = 0;
    int count = 0, sencount = 0;
    char characters[8], sentence[200];
    while (current < strlen(string)+1) {
        if (string[current] == '.' || string[current] == '-') {
            if (spaces > 3) sentence[sencount++] = ' ';
            characters[count++] = string[current];    
            spaces = 0;
        } else { 
            if (spaces == 0) {
                characters[count++] = 0;             
                sentence[sencount++] = morseToChar(characters);
                count = 0;
            }
            spaces++; 
        }
        current++;
    }
    sentence[sencount++] = '\0';
    printf("%s",sentence);
}

'''

在需要解码的摩尔斯文本中,每个字母之间有3个空格,单词之间有5个空格。我不明白为什么函数是这样构造的...

评论