?
sapero schrieb:
Hi, SYSTEMTIME members are two-byte words, word aligned, and sscanf returns at least 4 bytes for each %u token. When sscanf is returning temp2.wDay, then wDay and wHour is overwriten.
So, you'll need to pass temporary integer variables to sscanf, as you did in the first example.
Or just reorder date string to year.month.day or year.day.month.
typedef struct _SYSTEMTIME {WORD wYear, wMonth, wDayOfWeek, wDay, ...;
As you see, wYear is the first member, so keep the year as the first member of date string. Sscanf will overwrite wYear and wMonth while parsing/returning the year.
Damn... WORD... of course. The most simple solution. I normally try to avoid these WORD etc. macros of windows... because I never know what I really get. IMHO that is one additional obfuscation layer that could have been avoided if already the C/C++ designers would have had *well-defined* their variable types (i.e. that "int = 32 bit" would be universally valid) in the past.
Anyway - thanks a lot! I thought I was going crazy last night.