Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years ago.
Seperate many txt file in SD
Hi everyone~ Thx~ And i want to ask a question about Seperate many txt file in SD. Now i do is this picture. All data are in the same txt. But what i want is "one value with one txt". Example: sdtest1 has only "1" value .Next "1" will with stdtest2 ...... This is my code. Would someone can give me some point to solve this problem?
#include "mbed.h" #include "SDFileSystem.h" SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board Timer timer_w; Timer timer_s; int main() { timer_w.start(); timer_s.start(); mkdir("/sd/mydir", 0777); mkdir("/sd/mydir123", 0777); while(1){ if(timer_w.read() > 2){ FILE *fp = fopen("/sd/mydir/sdtest.txt", "a"); if(fp == NULL) { error("Could not open file for write\n"); } fprintf(fp,"%d\r\n",1); fclose(fp); timer_w.reset(); } } }
Thx very much!