我有以下代码:
struct coord {
float x;
float y;
};
struct coord vertices[4];
但是当我执行以下操作时,会发生错误:
void setVertices(float x, float y) {
vertices[0] = (struct coord) { x, y };
}
为什么C中不允许这样做?还有另一种方法吗?谢谢。
答案 0 :(得分:0)
实际上,我可以通过这种方式初始化结构。由于某种原因,IDE只是滞后于几分钟的错误检查。