C语言动态分配数组_一大块内存分配了,数据没有清空
#include "main.h" #include <stdio.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <limits.h> #include <signal.h> #include <string.h> #include <stdlib.h> #include <io.h> #define NUM 960 int main() { short* buf = NULL; buf = (short*)malloc(NUM*sizeof(short)); if(buf==NULL) { printf("buf is NULL\n"); } printf("%hd malloc\n",buf[0]); memset(buf,0,NUM*sizeof(short)); printf("%hd memset\n",buf[0]); free(buf); printf("%hd free\n",buf[0]); for(;;); return 0; }
一勤天下无难事。