【发布时间】:2020-03-23 13:39:15
【问题描述】:
错误是说: 'mypoint' 未在此范围内声明。
我的结构是
struct point
{
int x;
int y;
};
我的代码是:
struct point lineangle(int x1, int y1, int x2, int y2, int n){
double angle=360/n, s,c;
int rotated_x,rotated_y;
DDA(x1,y1,x2,y2);
for(int i=0;i<n;i++){
c = cos(angle*3.14/180);
s = sin(angle*3.14/180);
rotated_x= (x1 +((x2-x1)*c-(y2-y1)*s));
rotated_y= (y1 +((x2-x1)*s+(y2-y1)*c));
struct point mypoint[]={};
mypoint[i].x=x1;
mypoint[i].y=y1;
mypoint[i+1].x = rotated_x;
mypoint[i+1].y = rotated_y;
// DDA(x1,y1,rotated_x,rotated_y);
x2=rotated_x;
y2=rotated_y;
}
return mypoint;
}
我已声明但未检测到。
【问题讨论】:
-
选择 C 标签或 C++ 标签。
-
这能回答你的问题吗? C++ Return Array of Structs
-
@VladfromMoscow 你为什么把它重新标记为 C?标题是 C++。
-
@Chipster 因为他总是使用带有结构类型标识符的关键字 struct。好像是C代码。
-
@VladfromMoscow 虽然这看起来确实像 C,但可能是因为前 C 程序员正在使用 C++ 编程。不幸的是,我们现在只需要继续标题。