[Tux4kids-commits] r1088 - tuxmath/branches/lan/server

akash gangil gangil-guest at alioth.debian.org
Wed Jun 24 13:37:38 UTC 2009


Author: gangil-guest
Date: 2009-06-24 13:37:37 +0000 (Wed, 24 Jun 2009)
New Revision: 1088

Modified:
   tuxmath/branches/lan/server/testclient.c
Log:
Replaces all gets with fgets , now no compiler warnings

Modified: tuxmath/branches/lan/server/testclient.c
===================================================================
--- tuxmath/branches/lan/server/testclient.c	2009-06-24 03:42:55 UTC (rev 1087)
+++ tuxmath/branches/lan/server/testclient.c	2009-06-24 13:37:37 UTC (rev 1088)
@@ -97,11 +97,14 @@
              "'game' to start math game;\n"
              "'exit' to end client leaving server running;\n"
              "'quit' to end both client and server\n>\n"); 
-    scanf("%s", buffer);
-
+    char *check;
+    check=fgets(buffer,NET_BUF_LEN,stdin);
+    printf("buffer is %s",buffer);   
+    printf("check is %s",check);
+    printf("%d",strncmp(buffer, "quit",4));
     //Figure out if we are trying to quit:
-    if(  (strcmp(buffer, "exit") == 0)
-      || (strcmp(buffer, "quit") == 0))
+    if(  (strncmp(buffer, "exit",4) == 0)
+      || (strncmp(buffer, "quit",4) == 0))
     {
       quit = 1;
       len = strlen(buffer) + 1;
@@ -111,7 +114,7 @@
         exit(EXIT_FAILURE);
       }
     }
-    else if (strcmp(buffer, "game") == 0)
+    else if (strncmp(buffer, "game",4) == 0)
     {
       printf("Starting math game:\n");
       playgame();
@@ -288,7 +291,7 @@
           printf("command is %s\n", command);
 #endif
           /* Now we process the buffer according to the command: */
-          if(strcmp(command, "SEND_QUESTION") == 0)
+          if(strncmp(command, "SEND_QUESTION",13) == 0)
           {
             if(Make_Flashcard(buf, &flash))  /* function call to parse buffer into MC_FlashCard */
               have_question = 1; 
@@ -306,9 +309,11 @@
     //Now we check for any user responses
     while(have_question && !end)
     { 
+      char *check1;
       printf("Question is: %s\n", flash.formula_string);
       printf("Enter answer:\n>");
-      gets(buf);
+      check1=fgets(buf,NET_BUF_LEN,stdin);
+      printf("check is %s\n",check1);
       printf("buf is %s\n", buf);
       if ((strncmp(buf, "quit", 4) == 0)
         ||(strncmp(buf, "exit", 4) == 0)




More information about the Tux4kids-commits mailing list