ELEC350 - Team Q / Mbed 2 deprecated z_compare_commands

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
osmith2
Date:
Thu Jan 04 23:10:03 2018 +0000
Child:
1:81f52f1beb21
Commit message:
My working strcmp code

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jan 04 23:10:03 2018 +0000
@@ -0,0 +1,43 @@
+//http://www.cplusplus.com/reference/cstring/strcmp/
+
+#include "mbed.h"
+#include <string>
+
+Serial pc(USBTX, USBRX);
+
+
+DigitalOut myled(LED1);
+
+//THIS CODE DOESN'T WORK YET.
+//This may help http://www.cplusplus.com/reference/string/string/compare/
+
+
+int main() {
+        char key[] = "apple";
+        char key2[] = "pear";
+        char puttyBuffer[20];
+    
+    while(1) {
+        
+        myled = 1; // LED is ON
+        wait(1.0); // 200 ms
+        myled = 0; // LED is OFF
+        wait(1.0); // 1 sec
+        
+        //pc.printf("What is the password?\n");
+        pc.printf ("Please choose a fruit?\n");
+        fflush (stdout);
+        scanf ("%79s",puttyBuffer);        
+
+        if (strcmp (key,puttyBuffer) == 0){
+        puts ("Apple is delicious!\n");
+        }
+        else if (strcmp (key2,puttyBuffer) == 0){
+        puts ("Eww, pear is icky.\n");   
+        }
+        else{
+        puts ("try again loser!\n");
+        }
+    }
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jan 04 23:10:03 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/7130f322cb7e
\ No newline at end of file