标签:
三个函数的申明分别是:
void* malloc(unsigned size); void* realloc(void* ptr, unsigned newsize); void* calloc(size_t numElements, size_t sizeOfElement);
#include <stdio.h> #include <malloc.h> int main(int argc, char* argv[]) { char *p,*q; p = (char *)malloc(10); q = p; p = (char *)realloc(p,10); printf("p=0x%x/n",p); printf("q=0x%x/n",q); return 0; }
#include <stdio.h> #include <malloc.h> int main(int argc, char* argv[]) { char *p,*q; p = (char *)malloc(10); q = p; p = (char *)realloc(p,1000); printf("p=0x%x/n",p); printf("q=0x%x/n",q); return 0; }
标签:
原文地址:http://www.cnblogs.com/lujin49/p/4747072.html