了解K&R“ C编程语言”的getword()函数

因此,在K&R“ C编程语言”中,有一个名为getword()的函数,我不知道它是如何工作的。谁能帮我吗?我将函数发布在下面,因此没有人去寻找它。

/* getword: get next word or character input */
int getword(char *word, int lim){

        int c, getch(void);
        void ungetch(int);
        char *w = word;

        while(isspace(c = getch())){
        ;
        }

        if (c != EOF){
                *w++ = c;
        }
        if (!isalpha(c)){
                *w = '\0';
                return c;
        }
        for ( ; --lim > 0; w++){
                if (!isalnum(*w = getch())){
                        ungetch(*w);
                        break;
                }
        }
        *w = '\0';
        return word[0];
}