1个回答
展开全部
#include <stdlib.h>
void main()
{
int a[100];
int *b = (int *)malloc(100*sizeof(int));
if (b == NULL)
{
printf("malloc b failed\n");
return;
}
int *c;
int d;
printf("输入数组长度:");
scanf("%d", &d);
c = (int *)malloc(d*sizeof(int));
if (c == NULL)
{
printf("malloc b failed\n");
return;
}
else
{
printf("数组分配成功\n");
}
}
void main()
{
int a[100];
int *b = (int *)malloc(100*sizeof(int));
if (b == NULL)
{
printf("malloc b failed\n");
return;
}
int *c;
int d;
printf("输入数组长度:");
scanf("%d", &d);
c = (int *)malloc(d*sizeof(int));
if (c == NULL)
{
printf("malloc b failed\n");
return;
}
else
{
printf("数组分配成功\n");
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询