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.
main.cpp
00001 // a way to create incrementing filenames, sford 00002 // every time you hit reset, will create a file with incremental filename 00003 00004 #include "mbed.h" 00005 00006 LocalFileSystem local("local"); // Create the local filesystem under the name "local" 00007 00008 int main() { 00009 char filename[64]; 00010 int n = 0; 00011 00012 // set "filename" equal to the next file to write 00013 while(1) { 00014 sprintf(filename, "/local/file%03d.txt", n); // construct the filename fileNNN.txt 00015 FILE *fp = fopen(filename, "r"); // try and open it 00016 if(fp == NULL) { // if not found, we're done! 00017 break; 00018 } 00019 fclose(fp); // close the file 00020 n++; // and try the next one 00021 } 00022 00023 FILE *fp = fopen(filename, "w"); 00024 fprintf(fp, "I am file # %d\n", n); 00025 fclose(fp); 00026 }
Generated on Sat Jul 30 2022 03:05:01 by
1.7.2