diff options
| author | cgd <cgd@NetBSD.org> | 1993-12-22 07:23:27 +0000 |
|---|---|---|
| committer | cgd <cgd@NetBSD.org> | 1993-12-22 07:23:27 +0000 |
| commit | d9a38aee043007ddb33822f49e3e2067d6177fa5 (patch) | |
| tree | 5fb74ceefa186c34cea6385175100b7a3fb798de /quiz/quiz.c | |
| parent | 71b1ffbbef684c45fef47c5bbdb1221ed6614e74 (diff) | |
| download | bsdgames-darwin-d9a38aee043007ddb33822f49e3e2067d6177fa5.tar.gz bsdgames-darwin-d9a38aee043007ddb33822f49e3e2067d6177fa5.zip | |
update for fgetline
Diffstat (limited to 'quiz/quiz.c')
| -rw-r--r-- | quiz/quiz.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/quiz/quiz.c b/quiz/quiz.c index dddc1c96..c9b7134a 100644 --- a/quiz/quiz.c +++ b/quiz/quiz.c @@ -42,7 +42,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)quiz.c 5.1 (Berkeley) 11/10/91";*/ -static char rcsid[] = "$Id: quiz.c,v 1.3 1993/11/17 11:58:40 cgd Exp $"; +static char rcsid[] = "$Id: quiz.c,v 1.4 1993/12/22 07:23:27 cgd Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -136,6 +136,7 @@ get_file(file) if ((qp->q_next = malloc(sizeof(QE))) == NULL) err("%s", strerror(errno)); qp = qp->q_next; + lp[len - 1] = '\0'; if ((qp->q_text = strdup(lp)) == NULL) err("%s", strerror(errno)); qp->q_asked = qp->q_answered = FALSE; @@ -211,7 +212,7 @@ quiz() register QE *qp; register int i; u_int guesses, rights, wrongs; - int next; + int len, next; char *s, *t, question[LINE_SZ]; char *answer; @@ -261,10 +262,11 @@ quiz() qp->q_asked = TRUE; (void)printf("%s?\n", question); for (;; ++guesses) { - if ((answer = fgetline(stdin, NULL)) == NULL) { + if ((answer = fgetline(stdin, &len)) == NULL) { score(rights, wrongs, guesses); exit(0); } + answer[len - 1] = '\0'; downcase(answer); if (rxp_match(answer)) { (void)printf("Right!\n"); |
