diff options
Diffstat (limited to '6.6/word.c')
-rw-r--r-- | 6.6/word.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/6.6/word.c b/6.6/word.c new file mode 100644 index 0000000..7f26dfd --- /dev/null +++ b/6.6/word.c @@ -0,0 +1,26 @@ +#include <ctype.h> +#include <string.h> +#include "getch.h" +#include "word.h" + +char getword(char *word, int lim) +{ + char *w = word; + + if (isalpha(*w = getch())) { + while ((isalnum(*++w = getch()) || *w == '_') && --lim > 0) + ; + ungetch(*w--); + } + + *++w = '\0'; + return word[0]; +} + +void ungetword(char *word) +{ + int len; + + for (len = strlen(word); len >= 0; --len) + ungetch(word[len]); +} |