Hi, I'm really new to MBED and I have to make a program that writes data to local file every hour. Currently testing it out with 2 secs interval. I want the program to write into the same .txt file everytime. However, everytime it writes into localfile, it overwrites the current file, thus losing all previous data. Is there a way to make it write into the same file and not overwrite it? My code looks something like this:
LocalFileSystem local("local");
void DoSleep(void *) {
WFE();
}
void AlarmFn(void *) {
FILE *fp = fopen("/local/DayGen.txt", "w");
fprintf(fp, "Testing...");
fclose(fp);
}
int main() {
AlarmTimeDate::Init();
AlarmTimeDate a1(AlarmFn,NULL,seconds+2);
do {
FILE *fp = fopen("/local/DayGen.txt", "w");
fprintf(fp, "Hello World!!");
fclose(fp);
AlarmTimeDate::PrintAlarms();
AlarmTimeDate::Tick(DoSleep,NULL);
seconds+=2;
a1.Set(seconds);
} while(1);
}
Hi, I'm really new to MBED and I have to make a program that writes data to local file every hour. Currently testing it out with 2 secs interval. I want the program to write into the same .txt file everytime. However, everytime it writes into localfile, it overwrites the current file, thus losing all previous data. Is there a way to make it write into the same file and not overwrite it? My code looks something like this:
LocalFileSystem local("local");
void DoSleep(void *) { WFE(); }
void AlarmFn(void *) {
FILE *fp = fopen("/local/DayGen.txt", "w"); fprintf(fp, "Testing..."); fclose(fp); }
int main() {
AlarmTimeDate::Init(); AlarmTimeDate a1(AlarmFn,NULL,seconds+2);
do { FILE *fp = fopen("/local/DayGen.txt", "w"); fprintf(fp, "Hello World!!"); fclose(fp);
AlarmTimeDate::PrintAlarms(); AlarmTimeDate::Tick(DoSleep,NULL); seconds+=2; a1.Set(seconds); } while(1); }