0

i have a online logging of data through com port.
the c program captures the online data every 1 minute, calculates ten minute average, standard deviation and then writes it to a file.
the file is created with getdate function.
when the day changes, i have to create the new file with the new date which is not happening. can someone help.
i can send the code if interested.

--kumar

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Ancient Dragon
0

The way I did it was create a new filename every time I wanted to open the file. That way when the date changes my algorithm will automatically pick up the new date.

time_t now = time(0);
struct tm* tm = localtime(&now);
char filename[255];
sprintf(filename,"%04d%02d%02d", 
    tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday);
// now open the file
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.