date and time created 88/06/01 18:39:47 by bostic
[unix-history] / usr / src / games / quiz / quiz.c
index 5ca2cb7..1d28d60 100644 (file)
@@ -1,5 +1,5 @@
 
 
-static char sccsid[] = "       quiz.c  4.1     82/10/24        ";
+static char sccsid[] = "       quiz.c  4.4     88/01/02        ";
 
 #include <stdio.h>
 #include <signal.h>
 
 #include <stdio.h>
 #include <signal.h>
@@ -28,9 +28,11 @@ int select[NF];
 
 readline()
 {
 
 readline()
 {
+       register int ch;
        char *t;
 loop:
        char *t;
 loop:
-       for(t=line;(*t=getc(input))!=-1;t++) {
+       for(t=line;(ch=getc(input))!=-1;t++) {
+               *t = ch;
                nc++;
                if(*t==' '&&(t==line||t[-1]==' '))
                        t--;
                nc++;
                if(*t==' '&&(t==line||t[-1]==' '))
                        t--;
@@ -45,10 +47,10 @@ loop:
                if(t-line>=NC) {
                        printf("Too hard for me\n");
                        do {
                if(t-line>=NC) {
                        printf("Too hard for me\n");
                        do {
-                               *line = getc(input);
-                               if(*line==0377)
+                               if ((ch = getc(input)) == EOF)
                                        return(0);
                                        return(0);
-                       } while(*line!='\n');
+                       } while(ch!='\n');
+                       *line = '\n';
                        goto loop;
                }
        }
                        goto loop;
                }
        }
@@ -291,6 +293,8 @@ readindex()
 talloc()
 {
        int i;
 talloc()
 {
        int i;
+       char *malloc();
+
        for(i=0;i<NF;i++)
                tmp[i] = malloc(SL);
 }
        for(i=0;i<NF;i++)
                tmp[i] = malloc(SL);
 }
@@ -420,10 +424,12 @@ next()
 
 done()
 {
 
 done()
 {
-       printf("\nRights %d, wrongs %d, ", rights, wrongs);
-       if(guesses)
-               printf("extra guesses %d, ", guesses);
-       printf("score %d%%\n",100*rights/(rights+wrongs));
+       if (rights + wrongs) {
+               printf("\nRights %d, wrongs %d, ", rights, wrongs);
+               if (guesses)
+                       printf("extra guesses %d, ", guesses);
+               printf("score %d%%\n",100 * rights / (rights + wrongs));
+       }
        exit(0);
 }
 instruct(info)
        exit(0);
 }
 instruct(info)