gpt4 book ai didi

c - "array type has incomplete element type"

转载 作者:行者123 更新时间:2023-11-30 15:45:35 59 4
gpt4 key购买 nike

我是 C 编程新手,有以下代码。我面临以下错误。

typedef struct Vertex Vertex;
typedef struct Edge Edge;

struct Vertex {
bool known;
char id[25];
Edge edges[20];
int distance;
};

struct Edge {
Vertex target;
int weight;
};

typedef struct {
Vertex Nodes[20];
int pass;
int infinity;
} Graph;

它给出的错误是:

array type has incomplete element type

有人可以帮我理解问题所在吗?

最佳答案

typedef struct Vertex Vertex;
typedef struct Edge Vertex;

这可能会产生一些名称冲突,只需更改其中一个的名称即可。

关于c - "array type has incomplete element type",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18937822/

59 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com