SD card
Dependencies: ELEC350-Practicals-FZ429
Fork of Task680solution-mbed-os-FZ429ZI by
Revision 3:13716f14b257, committed 2017-11-23
- Comitter:
- noutram
- Date:
- Thu Nov 23 10:55:50 2017 +0000
- Parent:
- 2:fad34c30dcc4
- Child:
- 4:958cfd74ef1c
- Commit message:
- Solution
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Nov 22 15:18:28 2017 +0000
+++ b/main.cpp Thu Nov 23 10:55:50 2017 +0000
@@ -30,7 +30,7 @@
// Open to WRITE
// *************
printf("Write to a file\n");
- FILE* fp = fopen("/sd/test.txt","w");
+ FILE* fp = fopen("/sd/test.txt","a");
//Check file handle (stream)
if (fp == NULL) {
error("Could not open file for write\n");
@@ -53,11 +53,13 @@
errorCode(FATAL);
}
- //Read in three strings
- char s1[64], s2[64], s3[64];
- fscanf(fp, "%s %s %s", s1,s2,s3);
+ //Read back all strings
+ char s1[64];
+ while (fscanf(fp, "%s", s1) == 1) {
+ printf("READ BACK: %s\n", s1);
+ }
//To read a whole line, use: fgets(s1, sizeof(s1), fp);
- printf("READ BACK: %s %s %s\n", s1, s2, s3);
+
//Close File
fclose(fp);
