#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
main(){
int count, *array;
if((array = (int*) malloc(10*sizeof(int))) == NULL){
printf("不能成功分配存储空间");
exit(1);
}
for (count = 0; count < 10; count ++)
{
array[count] = count;
}
for (count = 0; count < 10; count ++)
{
printf("%2d", array[count]);
}
}
C语言malloc用法
最新推荐文章于 2024-03-29 22:21:38 发布