Hi,
I have an issue with creating and naming files for data storage.
This is the method I use now:
char filename[64];
sprintf(filename, "/local/analog_%d.txt", x);
FILE *fp = fopen(filename, "w");
where x is an incremented variable which changes after a file has been opened, so that the next file is named the next highest number.
Unfortunately, this limits me to 10 files at most.
Is there a simple solution to this?
here is what I thought of using:
char filename[64];
for (x=x; x<10; x=x) {
sprintf(filename, "/local/analog_000%d.txt", x);
}
for (x=x; 10<100; x=x) {
sprintf(filename, "/local/analog_00%d.txt", x);
}
for (x=x; 100<1000; x=x) {
sprintf(filename, "/local/analog_0%d.txt", x);
}
for (x=x; 1000<10000; x=x) {
sprintf(filename, "/local/analog_%d.txt", x);
FILE *fp = fopen(filename, "w");
But this is pretty ugly (plus it dosen't work, hangs up mbed on start-up)
any suggestions?
thanks
Hi,
I have an issue with creating and naming files for data storage.
This is the method I use now:
Unfortunately, this limits me to 10 files at most.
Is there a simple solution to this?
here is what I thought of using:
any suggestions?
thanks