mthoutai

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<malloc.h>
int main(void)
{
    int *str1 = NULL;
    int *str2 = NULL;
    str1 = (int*)malloc(2*1024*sizeof(char));
    if(str1==NULL)
    {
        printf("malloc error!\n");
        return -1;
    }
    printf("malloc:  %p\n", str1);
    str2 = (int*)realloc(str1,6*1024*sizeof(char));
    if(str2==NULL)
    {
        printf("realloc error!\n");
        return -1;
    }
    printf("realloc: %p\n",str2);
    free(str2);
    return 0;
}

 

posted on 2017-06-06 18:48  mthoutai  阅读(217)  评论(0编辑  收藏  举报