Possible Duplicate:
Returning local data from functions in C and C++ via pointer返回整数数组从功能不带参数
我需要创建一个函数没有参数,返回数组
我得到的错误:“警告:函数返回局部变量的地址”
我的代码已被简化的阅读
int * getNums()
{
int nums[8];
nums = {1,2,3,4,5,6,7,8};
return nums;
}
导致我明白,当函数结束的足尖,易于r丢失了,但阵列仍然会被发送?如果没有,在函数调用中返回没有参数的整型数组有什么好方法?
欣赏的帮助提前!
干杯
请注意,[数组和指针是不一样](http://stackoverflow.com/questions/1641957/is-array-name-a-pointer-in-c)。另请参见:[如何在C++中使用数组?](http://stackoverflow.com/questions/4810664/how-do-i-use-arrays-in-c)。 – sbi 2011-05-03 08:30:35