games/boggle/boggle/mach.c
/*
 * Get a word from the user and check if it is in either of the two
 * word lists
 * If it's found, show the word on the board for a short time and then
 * erase the word
 *
 * Note: this function knows about the format of the board
 */
Get a word from the user and check if it is in either of the two
word lists
If it's found, show the word on the board for a short time and then
erase the word

this function knows about the format of the board
Get a word from the user and check if it is in either of the two word lists If it ' s found show the word on the board for a short time and then erase the word this function knows about the format of the board
void
findword()
{
	int c, col, found, i, r, row;
	char buf[MAXWORDLEN + 1];
	extern char board[];
	extern int usedbits, wordpath[];
	extern char *mword[], *pword[];
	extern int nmwords, npwords;
	getyx(stdscr, r, c);
	getword(buf);
	found = 0;
	for (i = 0; i < npwords; i++) {
		if (strcmp(buf, pword[i]) == 0) {
			found = 1;
			break;
		}
	}
	if (!found) {
		for (i = 0; i < nmwords; i++) {
			if (strcmp(buf, mword[i]) == 0) {
				found = 1;
				break;
			}
		}
	}
	for (i = 0; i < MAXWORDLEN; i++)
		wordpath[i] = -1;
	usedbits = 0;
	if (!found || checkword(buf, -1, wordpath) == -1) {
		move(r, c);
		clrtoeol();
		addstr("[???]");
		refresh();
		delay(10);
		move(r, c);
		clrtoeol();
		refresh();
		return;
	}
	standout();
	for (i = 0; wordpath[i] != -1; i++) {
		row = BOARD_LINE + (wordpath[i] / 4) * 2 + 1;
		col = BOARD_COL + (wordpath[i] % 4) * 4 + 2;
		move(row, col);
		if (board[wordpath[i]] == 'q')
			printw("Qu");
		else
			printw("%c", toupper(board[wordpath[i]]));
		move(r, c);
		refresh();
		delay(5);
	}
	standend();
	for (i = 0; wordpath[i] != -1; i++) {
		row = BOARD_LINE + (wordpath[i] / 4) * 2 + 1;
		col = BOARD_COL + (wordpath[i] % 4) * 4 + 2;
		move(row, col);
		if (board[wordpath[i]] == 'q')
			printw("Qu");
		else
			printw("%c", toupper(board[wordpath[i]]));
	}
	move(r, c);
	clrtoeol();
	refresh();
}
void findword ( ) { int c , col , found , i , r , row ; char buf [ MAXWORDLEN + 1 ] ; extern char board [ ] ; extern int usedbits , wordpath [ ] ; extern char * mword [ ] , * pword [ ] ; extern int nmwords , npwords ; getyx ( stdscr , r , c ) ; getword ( buf ) ; found = 0 ; for ( i = 0 ; i < npwords ; i ++ ) { if ( strcmp ( buf , pword [ i ] ) == 0 ) { found = 1 ; break ; } } if ( ! found ) { for ( i = 0 ; i < nmwords ; i ++ ) { if ( strcmp ( buf , mword [ i ] ) == 0 ) { found = 1 ; break ; } } } for ( i = 0 ; i < MAXWORDLEN ; i ++ ) wordpath [ i ] = -1 ; usedbits = 0 ; if ( ! found || checkword ( buf , -1 , wordpath ) == -1 ) { move ( r , c ) ; clrtoeol ( ) ; addstr ( " " ) ; refresh ( ) ; delay ( 10 ) ; move ( r , c ) ; clrtoeol ( ) ; refresh ( ) ; return ; } standout ( ) ; for ( i = 0 ; wordpath [ i ] != -1 ; i ++ ) { row = BOARD_LINE + ( wordpath [ i ] / 4 ) * 2 + 1 ; col = BOARD_COL + ( wordpath [ i ] % 4 ) * 4 + 2 ; move ( row , col ) ; if ( board [ wordpath [ i ] ] == ' ' ) printw ( " " ) ; else printw ( " " , toupper ( board [ wordpath [ i ] ] ) ) ; move ( r , c ) ; refresh ( ) ; delay ( 5 ) ; } standend ( ) ; for ( i = 0 ; wordpath [ i ] != -1 ; i ++ ) { row = BOARD_LINE + ( wordpath [ i ] / 4 ) * 2 + 1 ; col = BOARD_COL + ( wordpath [ i ] % 4 ) * 4 + 2 ; move ( row , col ) ; if ( board [ wordpath [ i ] ] == ' ' ) printw ( " " ) ; else printw ( " " , toupper ( board [ wordpath [ i ] ] ) ) ; } move ( r , c ) ; clrtoeol ( ) ; refresh ( ) ; }
Get a word from the user and check if it is in either of the two
 word lists
 If it's found, show the word on the board for a short time and then
 erase the word
Get a word from the user and check if it is in either of the two word lists If it ' s found show the word on the board for a short time and then erase the word