Junyu Lu
/
Nucleo_printf
123
Diff: main1.cpp
- Revision:
- 0:3c8241f877e9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main1.cpp Tue Oct 01 22:28:19 2019 +0000 @@ -0,0 +1,17 @@ +#include "mbed.h" + +LocalFileSystem local("local"); // Create the local filesystem under the name "local" + +int main() { + FILE *fp = fopen("/local/out.txt", "w"); // Open "out.txt" on the local file system for writing + fprintf(fp, "Hello World!"); + fclose(fp); + remove("/local/out.txt"); // Removes the file "out.txt" from the local file system + + DIR *d = opendir("/local"); // Opens the root directory of the local file system + struct dirent *p; + while((p = readdir(d)) != NULL) { // Print the names of the files in the local file system + printf("%s\n", p->d_name); // to stdout. + } + closedir(d); +}