In C programming, when I try to execute for the first time, I need
TCHAR file_name[1024]; // Use memset or set the first byte to 0? file_name[0] = 0; _tcscat(file_name, TEMP_DIRECTORY_PATH); _tcscat(file_name, file);
I see that most programmers use memset. But for me, I just set the first byte to 0 so that _tcscat knows where to start.
I'm not sure if there is a flaw / trap for this, instead of using memset?
Thank.
You can simply set the first char to 0.
However, it will be even easier
TCHAR file_name[1024]; _tcsncpy(file_name, TEMP_DIRECTORY_PATH, 1024); _tcscat(file_name, file);
, , , , 0 . / , - , ( , , , ).
strcpy(), , , strcat() ` ( , 1- 0).
strcpy()
, "sensitve" ( - ) - , . , http://msdn.microsoft.com/en-us/library/ms972826 , memset() .
memset()
, , , null , .. - . , , .
NUL - " " . , , , . , , , , NUL. NUL , "". " ", , , .
, NUL, " " , . NUL - . , . , " " , , , , ....
, , . , .