so im trying to convert my code from localtime to localtime_s.
it was this:

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

i seem to be having some strctual errors. Can i have some help?

The issue is that localtime and localtime_s are slightly different. The _s stands for safe, it is a memory safe version of localtime. As such it does not create it's own tm* to return, rather you have to send it one. The correct code would be:

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

Thank you kind sir/ma'am
edit: put it in. it says it has no stroage class or type specifer. to be honest i feel a bit slow.

Let me take a look at the exact code that you used (just from creation of the time_t to the call of localtime_s) I'll see if I can figure out what went wrong.

idk how it worked in the first place. i have it in two places
ive had this before the main

time_t now = time(0);
tm *ltm = localtime(&now);

and this 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;

cout << "Any Key to Begin" << endl;
getch();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.