struct Node {
int element;
struct Set *next;
};
struct Set {
struct Set *head;
struct Set *tail;
};
struct Set SET_union(struct Set s, struct Set t) {
struct Set u = SET_new();
struct Node *node = s.head;
for (node = s.head; node != NULL; node = node->next) {
SET_add(&u, node->element);
}
for (node = t.head; node != NULL; node = node->next) {
if (!SET_contains(&u, node->element))
SET_add(&u, node->element);
}
return u;
}
...
printf("%i\n", SET_union(set, set1));
运行此代码时,SET联合会将内存地址返回到返回的集合,而不是新创建的集合中的元素。如何获得函数以返回集合中的元素?