Leonardo Sarra / Mbed OS iot_exercise_1

Files at this revision

API Documentation at this revision

Comitter:
LithiumSR
Date:
Fri Mar 01 15:21:53 2019 +0000
Parent:
4:979929c6d0b7
Commit message:
Add support for the ASCII format when the users responds

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Mar 01 00:42:06 2019 +0000
+++ b/main.cpp	Fri Mar 01 15:21:53 2019 +0000
@@ -56,7 +56,8 @@
     while(1){
         if (pc.readable()){
            timeout_triggered = false;
-           return pc.getc();
+           char got = pc.getc();
+           return atoi(&got);
         } else if (timeout_triggered) {
             timeout_triggered = false;
             return 0;
@@ -113,7 +114,7 @@
                 printf("No questions avaialable!\n");
                 print_score(map);
                 break;
-                }
+            }
             game_progress = true;
             vector<string> ret = get_answers_vector(domanda);
             printf("%s\n",ret.at(0).c_str());
@@ -131,14 +132,14 @@
             if (answer!=0 && ret.at(--answer)==correct_answer) {
                 printf("CORRECT!\n");
                 map[user]++;
-                }
+            }
             else printf("WRONG!\n");
             game_progress = false;
             user++;
             if (user == users) {
                 user=0;
                 round++;
-                }
+            }
         }
 
         // Check if game has ended