aboutsummaryrefslogtreecommitdiff
path: root/6.4/word.c
diff options
context:
space:
mode:
authorsinanmohd <sinan@firemail.cc>2023-05-08 16:59:02 +0530
committersinanmohd <sinan@firemail.cc>2023-05-09 10:26:15 +0530
commit3f761f64d02480c81177e39af2f00f0e76b6f113 (patch)
tree5df4e643cce5e626fc00af16935616ea0df40927 /6.4/word.c
parent2bc5c4c55b979af164c0bf7539e4f0bae6c263e8 (diff)
6.4: initial comiit
Diffstat (limited to '6.4/word.c')
-rw-r--r--6.4/word.c20
1 files changed, 20 insertions, 0 deletions
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 <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];
+}