Why is there garbage in my TCHAR, even after ZeroMemory()?

Posted by samoz on Stack Overflow See other posts from Stack Overflow or by samoz
Published on 2010-05-20T18:07:30Z Indexed on 2010/05/20 18:10 UTC
Read the original article Hit count: 140

Filed under:
|
|
|

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! Can someone explain what is going on and how to fix it?

© Stack Overflow or respective owner

Related posts about Windows

Related posts about c++