aboutsummaryrefslogblamecommitdiff
path: root/6.6/word.c
blob: 7f26dfd1b4c5f5b491fc95580f0ef28bf182fc6b (plain) (tree)

























                                                                           
#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]);
}