aboutsummaryrefslogtreecommitdiff
path: root/6.6/word.c
diff options
context:
space:
mode:
authorsinanmohd <sinan@firemail.cc>2023-05-10 09:48:22 +0530
committersinanmohd <sinan@firemail.cc>2023-05-10 18:05:15 +0530
commitbfe41ee41ad751c558a4483cfdf6317ac3a3d506 (patch)
tree1aa113258f19959c22187932292ea1f7968b7d27 /6.6/word.c
parent5c032ac33810cc3d01bdcc1cdb12bc8b913a696c (diff)
6.6 initial commit (better ../6.5)
Diffstat (limited to '6.6/word.c')
-rw-r--r--6.6/word.c26
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]);
+}