So decided I should switch to VS13 for the added benefits. Copied the cold, transfered the files, alls good right? Wrong. Actually its not that bad. Just one main problem.


See this fella? This is the one guy that is standing in the way of me and the debachury that i am programing. He is the name of my pointer for the time aspect of my program. so...


He and his buddies are throughout my 500+ line program that functioned fine in Bloodshed. The problem? VS13 doesnt play friendly with localtime (they dated once and had a fall out because localtime left VS some security breaches. The txt every now and then but are just drifting apart. and dad VS he didnt trust localtime.). VS knows what it likes. localtime has a brother.


safe, secure, dad likes localtime_s too! awesome! So to make sure things go well, is there a way to change localtime for localtime_s without having to change all of my little ltm's? please be gentle and tell my program she is [c]ute (NSFW). here is a peak at the goods (she is a naughty girl).

//before the main
time_t now = time(0);
tm *ltm = localtime(&now);

//in the main
time_t rawtime;
struct tm * timeinfo;
char buffer [80];

time (&rawtime);
timeinfo = localtime (&rawtime);

strftime (buffer,80,"logs\\%d%m%Y.dat",timeinfo);

//save date
show_date[0] = 1 + ltm->tm_mon;
show_date[1] = ltm->tm_mday;
show_date[2] = 1900 + ltm->tm_year;
2 Years
Discussion Span
Last Post by JasonHippy

As Labdabeta pointed out in your other thread, localtime_s takes a pointer to a tm struct as the 1st parameter and a pointer to a time_t as the 2nd.
So this is all you need:

time_t now = time(0);
tm ltm;
localtime_s(&ltm, &now);

Instead of a tm pointer, you now have a local instance of the tm struct and you pass a pointer to it to the localtime_s function.

With the above changes in place, the last piece of the puzzle should be to swap out the uses of the arrow operator for the dot operator in your other uses of ltm.
ltm->tm_mon in line 16 of your snippet becomes ltm.tm_mon etc.

This topic has been dead for over six months. 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.