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
");
    }
    printf("%hd malloc
",buf[0]);
    memset(buf,0,NUM*sizeof(short));
    printf("%hd memset
",buf[0]);
    free(buf);
    printf("%hd free
",buf[0]);
    for(;;);
    return 0;
}

  

一勤天下无难事。
原文地址:https://www.cnblogs.com/nowroot/p/13710654.html