1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#include <ctype.h> #include "getch.h" #include "word.h" char getword(char *word, int lim) { char *w = word; while (isblank(*w = getch())) ; if (isalpha(*w)) { while ((isalnum(*++w = getch()) || *w == '_') && --lim > 0) ; ungetch(*w--); } *++w = '\0'; return word[0]; }