From 3f761f64d02480c81177e39af2f00f0e76b6f113 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Mon, 8 May 2023 16:59:02 +0530 Subject: 6.4: initial comiit --- 6.4/word.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 6.4/word.c (limited to '6.4/word.c') diff --git a/6.4/word.c b/6.4/word.c new file mode 100644 index 0000000..c5a6381 --- /dev/null +++ b/6.4/word.c @@ -0,0 +1,20 @@ +#include +#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]; +} -- cgit v1.2.3