untested

Dependencies:   SDFileSystem mbed

Revision:
0:276de3654c32
Child:
2:1ee5d99a9bae
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Nov 04 18:26:55 2017 +0000
@@ -0,0 +1,41 @@
+#include "mbed.h"
+#include <string>
+#include <iostream>
+using namespace std;
+//Emic 2 Hello Speech World Demo
+#include "SDFileSystem.h"
+
+SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
+
+DigitalOut myled(LED1);
+
+int main()
+{
+    char delimiter = ',';
+    string letter[2];
+    string word[1];
+    char check;
+    string temp;
+    string tempword;
+    int counter = 0;
+    FILE *fp = fopen("/sd/plan.txt", "r"); //create file
+    while (!feof(fp)) {                       // while not end of file
+        check = fgetc(fp);                         // get data from the file
+        if(check == '\n') {
+            counter = 0;
+            check = fgetc(fp);
+            tempword = check;
+        } else if(tempword.length() != 0) {
+            tempword = tempword + check;
+        } else if(check != delimiter) {
+            temp = check;
+        } else if((check == delimiter) && (temp.length() == 1)) {
+            letter[counter] = temp;
+            counter = counter + 1;
+        } else {
+            word[counter] = tempword;
+            counter = counter + 1;
+        }
+    }
+    fclose(fp); //close file
+}