![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Oppgave 9.2b
Dependencies: mbed
main.cpp
- Committer:
- Smashftw
- Date:
- 2017-10-31
- Revision:
- 0:1fb92a5d9c43
File content as of revision 0:1fb92a5d9c43:
#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; }