Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Task690-mbed-os-FZ429ZI by
Diff: main.cpp
- Revision:
- 3:22e5460a8b42
- Parent:
- 2:fad34c30dcc4
- Child:
- 4:04cd5171c7ff
diff -r fad34c30dcc4 -r 22e5460a8b42 main.cpp
--- a/main.cpp Wed Nov 22 15:18:28 2017 +0000
+++ b/main.cpp Thu Nov 23 10:54:42 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);
