Oppgave 9.3b

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Smashftw
Date:
Tue Oct 31 12:53:19 2017 +0000
Commit message:
Oppgave93b

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
diff -r 000000000000 -r e3cc80ff6fe4 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Oct 31 12:53:19 2017 +0000
@@ -0,0 +1,28 @@
+#include "mbed.h"
+LocalFileSystem local("local");
+Serial pc(USBTX, USBRX);
+
+int main()
+{
+    FILE *fp = fopen("/local/treasure.txt", "r");
+    if (fp == NULL) { // Feil i åpning av fil
+        pc.printf("Feil i fopen\n");
+        return 1;
+    }
+
+    // Read file character by character - max 1000 chars
+    int cnum = 0;
+    int ch;
+    while ((ch = fgetc(fp)) != EOF) {
+       
+        cnum++;
+        if(cnum > 999) {
+        pc.printf("Antall tegn: %d", ch);
+        break;
+       
+        }
+    }
+   
+    fclose(fp);
+    return 0;
+}
diff -r 000000000000 -r e3cc80ff6fe4 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Oct 31 12:53:19 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/fb8e0ae1cceb
\ No newline at end of file