首页 > 其他 > 详细

使用malloc分别分配2KB,6KB的内存空间,打印指针地址

时间:2014-09-18 14:55:34      阅读:202      评论:0      收藏:0      [点我收藏+]
#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));
    str2 = (int*)malloc(6*1024*sizeof(char));
    if(str1==NULL || str2==NULL)
    {
        printf("malloc error!\n");
        return -1;
    }
    printf("2KB addr: %p\n6KB addr: %p\n", str1,str2);
    free(str1);
    free(str2);
    return 0;
}

 

使用malloc分别分配2KB,6KB的内存空间,打印指针地址

原文:http://blog.csdn.net/u013012494/article/details/39370807

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!