|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T w
Length: 1152 (0x480)
Types: TextFile
Names: »wordguess.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/General/Hangman1/wordguess.c«
/* wordguess.c
* code to guess the whole word
* written by: ritcv!jxs7451
*/
#include "hangman.h"
#include<stdio.h>
#include<strings.h>
wordguess(word)
char word[];
{
char fguess[MAXLINE]; /* holds user guess */
int i; /* loop counter */
reset_term();
for(i=0;(fguess[i] = getchar()) != '\n';i++)
{
if (i > (MAXLINE - 1))
{
while (getchar() != '\n') ; /* cl buffer */
init_term();
clbtm();
setcur(ERROR,1);
printf("Guess too long.");
return(0);
}
if (fguess[i] == EOF)
{
printf("\n\nunexpected EOF. Quitting hangman %s.\n",VERSION);
exit(0);
}
}
fguess[i] = '\0';
init_term();
clbtm();
setcur(ERROR,1);
printf("Your guess is '%s'.\n",fguess);
erasel(0,0);
printf("Are you sure(y/n) ");
i = getchar();
if ((i != 'y') && (i != 'Y'))
{
clbtm();
setcur(ERROR,1);
puts("The guess was not tried.");
return(0);
}
else /* trying it */
if (!strcmp(fguess,word))
return(1); /* win */
else
return(2); /* lose */
}