aboutsummaryrefslogtreecommitdiff
path: root/6.4/word.c
blob: c5a6381020043b92d1f5ebf99ca2225e94af1556 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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];
}