diff options
Diffstat (limited to '6.3/word.c')
-rw-r--r-- | 6.3/word.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/6.3/word.c b/6.3/word.c new file mode 100644 index 0000000..c5a6381 --- /dev/null +++ b/6.3/word.c @@ -0,0 +1,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]; +} |