C++代码提示:
warning: address of stack memory associated with local variable 'd' returned
代码:
//角度转度分秒
double* degreeToDegree(double degree)
{
//...
double d[3];
//...
return d; //warning提示...
}
要返回的是一个double数组d, return d的语句出现了警告。
解决办法:为数组增加 static 修饰符:
//...
static double d[3];
//...
return d;