用meset对数组内存清零后,里面全是字符‘\0’,总长度为0,所占内存为261..
#include <windows.h> #include <tchar.h> #include<stdio.h> void main() { TCHAR szMemSet[MAX_PATH+1]; LPTSTR lpMemSetSpace = (LPTSTR) malloc (sizeof(TCHAR)*261) ; memset(szMemSet,0,MAX_PATH+1); printf("%d,%d\n",strlen(szMemSet),sizeof(szMemSet)); memset(lpMemSetSpace,0,MAX_PATH+1); printf("%d,%d\n",strlen(lpMemSetSpace),sizeof(lpMemSetSpace)); }