如何在C++ 中实现函数 realloc(),具体代码如下:
如何在C++ 中实现函数 realloc(),具体代码如下:
int main(void)
{
char *str;
/* allocate memory for string */
str = (char *) malloc(10);
/* copy "Hello" into string */
strcpy(str, "Hello");
printf("String is %s\n Address is %p\n", str, str);
str = (char *) realloc(str, 20);
printf("String is %s\n New address is %p\n", str, str);
/* free memory */
free(str);
return 0;
}
问题点数:20、回复次数:1Top
1 楼Areece(Keen on Guru)回复于 2002-10-31 10:16:22 得分 20
C++中不是有这个函数吗
#include <stdlib.h>Top




