From bfe41ee41ad751c558a4483cfdf6317ac3a3d506 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Wed, 10 May 2023 09:48:22 +0530 Subject: 6.6 initial commit (better ../6.5) --- 6.6/word.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 6.6/word.c (limited to '6.6/word.c') 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 +#include +#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]); +} -- cgit v1.2.3