malloc 与 realloc <转>
摘要:
首先看个问题程序(这里用的是TC编译器):#include "stdlib.h"#include "stdio.h"void main(){int *i;i=(int *)malloc(sizeof(int));*i=1;*(i+1)=2;printf("%x|%d/n",i,*i);printf("%x|%d",i+1,*(i+1));}输出的结果是:8fc|18fe|2这个程序编译通过,运行正常,说它有问题,问题出在哪呢?首先通过malloc,建了一个大小为2的堆,i指向的地址是8fc,i+1指向的地址是8fc 阅读全文
posted @ 2012-07-30 12:29 greyfox 阅读(114) 评论(0) 推荐(0) 编辑