C语言传递数组指针如何消除警告? [Warning] assignment makes pointer from integer without a cast

来源:百度知道 编辑:UC知道 时间:2024/06/16 05:40:57
主文件ddd.c
#include "test.h"
int main()
{
int *aaa;
aaa = test_h();
printf("%d\n",aaa[0]);
}

另外一个文件test.h

static int iii[]={38,9999,10000};
int *test_h(void)
{
return iii;
}

用的是devC,出现警告[Warning] assignment makes pointer from integer without a cast,再次编译又没有警告,任意修改文件,又出现警告。
怎么解决?
malloc()怎么用,能否给个例子?

先用malloc()分配些空间试试看
devC没用过,不过应该大同小异,直接定义指针不分配空间便赋值的话仿佛都有警告的
顺带别忘记free掉~~~~~

我这里运行是没有警告的 (VC)