I have inherited the following line of code:
TCHAR temp[300];
GetModuleFileName(NULL, temp, 300);
However, this fails as the first 3 bytes are filled with garbage values (always the same ones though, -128, -13, 23, in that order). I said, well fine and changed it to:
TCHAR temp[300];
ZeroMemory(temp, 300);
GetModuleFileName(NULL, temp, 300);
but the garbage values persisted! Note that after the ZeroMemory() call, all other bytes were zeroed out properly and after GetModuleFileName(), the directory was stored in the buffer properly. It's as if temp was being replaced by temp+3. Could this have something to do with word boundaries?
Can someone explain what is going on and how to fix it?