C语言 malloc()与sizeof运算的盲点

//malloc()与sizeof运算的盲点
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void main()
{
    char *p = (char *)malloc(sizeof(char)*100);
    printf("%d
",siezof(p));//打印4
    /*
    malloc函数分配的内存,使用memset()函数的时候要注意,
    指针p的大小是4个字节,不要使用sizeof(p),这是错误的
    */
    memset(p, 0, sizeof(p));//错误
    free(p);
    system("pause");
}
原文地址:https://www.cnblogs.com/zhanggaofeng/p/6063167.html