I have a file filled with data, one column of which is in seconds from Epoch. For reference, the approximate value looks like this:
1498493536984926976
I need to convert it to the day of the year. What I have so far is the piece of code that uses this link to convert the date to a normal readable structure, and then strftime to get the day of the year out of the structure:
time_t rawtime = stol(exploded_line[2]);
std::cout << rawtime << std::endl;
struct tm date;
date = *localtime( &rawtime );
char *buffer;
std::cout << 2 << std::endl;
strftime (buffer,sizeof(buffer),"%j",&date);
However, this code is SegFaultson the line strftime! I have no idea what causes this. I tried to initialize bufferas
char buffer[80];
and various other ads, but nothing works. I also tried cutting out the buffer completely and just used std::string; that didn't work either.
, . - , .
!