Hi Everyone,
Been a while since I've posted on here!
So, I'm working on some C code for a data acquisition system to read out PMTs. That part hasn't been too bad, but I'm having a weird issue with writing the data out to a file.
When I have a test case set up, I should write a 120 kB to a file that's timestamped with the time the program runs.
However, my problem is that when I write the file, it writes a number of files with a new seconds timestamp! Each one is 120kB! It's absolutely baffling to me.
Here's some code:
I find the timestamp this way:
When I sprintf this string into a filename and write it, it writes what seem to be 6 files (or more, depending on how many seconds the program runs.) which look like so:Code:time(&curr_time); time_info = gmtime(&curr_time); strftime(new_time, 80, "%a_%b_%d_%Hh_%Mm_%Ss", time_info);
test_prefix_Tue_Jan_24_18h_25m_18s_suffix.dat
test_prefix_Tue_Jan_24_18h_25m_19s_suffix.dat
test_prefix_Tue_Jan_24_18h_25m_20s_suffx.dat
test_prefix_Tue_Jan_24_18h_25m_21s_suffix.dat
Where the first file is the filename I actually created, opened, and wrote.
What's weird is that, if I drop the %S modifier in the format string, there is only one file written at that particular time. This file is then the correct one.
Moreover, what's more weird is that if I print out every single time I close a file, there's only one fclose and one fopen operation in my program.
This problem is totally baffling to me. I'm using Microsoft Visual Studio C++ (and associated compilers) to develop this code (even though it's in C) since I need to be making DLLs to link into a Labview program. Is this a windows development environment kind of thing? Is the nature of the memory assigned for the time object and string tripping me up here?
Thanks for any help!