代碼正在工作,但出現錯誤。返回數組 使用返回引用這個函數 - > void alloc(int ** array,int size)。你怎麼看待這個錯誤?C中的動態數組分配
#include <stdio.h>
#include <stdlib.h>
void memoryys(int **array, int size);
int main()
{
int i;
int in;
int *a1;
printf("please number of elements ");
scanf("%d",in);
alloc(&a1,in);
for(i=0;i<in;i++){
scanf("d ",&a1[i]);
}
free(a1);
return 0;
}
void alloc(int **array, int size){
int i;
*array = (int *) malloc(size*sizeof(int));
if (*array == NULL){
printf("Error\n");
exit(-1);
}
}
不要在C.投'malloc' – crashmstr 2014-10-07 19:11:17
'的scanf( 「d」,&A1 [我]);' - >'scanf(「%d」,&a1 [i]);' – BLUEPIXY 2014-10-07 19:37:13
謝謝你的回答... – HUDUT 2014-10-07 19:52:30