你想返回一个数组,因为你在一个函数内创建了数组,属于局部变量,所以他在stack部分,而stack部分是用后类似于销毁的,你返回的地址类似于一块垃圾的地址,所以编译警告。你要想返回函数内创建的数组地址的话需要//inside a function{
// n is the size of the array;
int* array = (int *)malloc(sizeof(int)*n);
/*
do something with array
*/
return array;}这样这个数组建立在heap堆上,调用完函数还在,而你返回了那个堆上数组的首地址,这样就没问题了。用完free(arr...