I have the following code which is supposed to convert the time a file was last edited, to a struct tm value that I can use with strftime(). I know I don't need to do this as I can use much easier ways, but there is a reason it must be done like this.
When the code gets to the strftime() function, its stops and performs an illegal operation, saying it can't access that address (or some message along those lines).
struct tm * tm_date = new tm;
hFind = FindFirstFile("C:\\SWS\\testlog.txt", &FindData);
tm_date->tm_hour = myTime.wHour;
tm_date->tm_min = myTime.wMinute;
tm_date->tm_mday = myTime.wDay;
tm_date->tm_mon = myTime.wMonth;
tm_date->tm_sec = myTime.wSecond;
tm_date->tm_year = myTime.wYear - 1900;
strftime(Buffer, sizeof(Buffer), "%A, %x %X %p", tm_date);
cout << Buffer << endl;
Can anyone see what I'm doing wrong? I expect it has something to do with the pointers, because I always have problems with them. Thanks very much for any help, this means a lot to me.