Oppgave 9.2b
Dependencies: mbed
Revision 0:1fb92a5d9c43, committed 2017-10-31
- Comitter:
- Smashftw
- Date:
- Tue Oct 31 12:44:49 2017 +0000
- Commit message:
- Oppgave 9.2b
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 1fb92a5d9c43 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 31 12:44:49 2017 +0000 @@ -0,0 +1,34 @@ + +#include "mbed.h" +LocalFileSystem local("local"); +Serial pc(USBTX, USBRX); + +int main() +{ + char line[120]; + + 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 line by line - max 100 lines + int lnum = 0; + for(lnum = 0; lnum < 999; lnum ++){ + fscanf(fp, "%*[^\n]\n"); + } + while (fgets(line, 159, fp) != NULL) { + + pc.puts(line); + wait_ms(20); + lnum++; + + if (lnum > 1049) { + break; + } + } + fclose(fp); + return 0; +} +
diff -r 000000000000 -r 1fb92a5d9c43 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Oct 31 12:44:49 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/fb8e0ae1cceb \ No newline at end of file