electricperi 2014-08-16
一、程序C语言代码展示如下:
/************************************************
运行平台:vc++6.0
实现功能:体现realloc函数的作用
************************************************/
#include<stdio.h>
#include<stdlib.h>
#define NUM1 5
#define NUM2 10
int main(void)
{
int i = 0;
int *point = (int *)malloc(NUM1*sizeof(int));
printf("malloc指针point的值为:%p\n", point);
printf("为point[%d]~point[%d]赋值:\n", 0, NUM1-1);
for(i=0; i<NUM1; i++)
{
scanf("%d", &point[i]);
}
printf("point[%d]~point[%d]的值为:\n", 0, NUM1-1);
for(i=0; i<NUM1; i++)
{
printf("%2d", point[i]);
}
printf("\n\n");
point=(int *)realloc(point, NUM2*sizeof(int));
printf("realloc指针point的值为:%p\n", point);
printf("为point[%d]~point[%d]赋值:\n", NUM1, NUM2-1);
for(i=NUM1; i<NUM2; i++)
{
scanf("%d", &point[i]);
}
printf("point[%d]~point[%d]的值为:\n", 0, NUM2-1);
for(i=0; i<NUM2; i++)
{
printf("%2d", point[i]);
}
printf("\n");
free(point);
return 0;
}
将C语言梳理一下,分布在以下10个章节中: