malloc和free函数的使用

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int *p,t;
    p = (int *)malloc(40*sizeof(int));
    if (!p){
        printf("内存已用完!j");
        exit(0);

    }
    for (t=0;t<40;++t) *(p+t)=t;
    for (t=0;t<40;++t)
    {
        if (t%5==0)putchar('
');
        printf("%2d	",*(p+t));
    }
    free(p);
    return 0;
}
原文地址:https://www.cnblogs.com/fazero/p/4616998.html