Hey,
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.
Code:
SYSTEMTIME myTime;
struct tm * tm_date = new tm;
HANDLE hFind;
WIN32_FIND_DATA FindData;
char Buffer[1000];
hFind = FindFirstFile("C:\\SWS\\testlog.txt", &FindData);
FileTimeToSystemTime(&FindData.ftCreationTime, &myTime);
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;
delete tm_date;
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).
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.