【发布时间】:2020-08-29 11:55:38
【问题描述】:
我正在使用这个函数来创建一个链表,其中每个节点都是一副完整牌组中的一张牌,但是我遇到了这个奇怪的错误。有什么帮助吗?
typedef struct cards
{
char card[3];
struct cards * next;
} cards_t;
cards_t * make_list(char ** deck) //function to make list
{
int j = 0;
cards_t *head = malloc (sizeof(cards_t));
for (cards_t * iterator = head; j<52; iterator = iterator->next, j++)
{
iterator->card = deck[j];
iterator->next = malloc(sizeof(cards_t));
}
return head;
}
【问题讨论】:
-
card是一个数组,不能作为=运算符的LHS。 -
我该如何解决它
标签: c arrays compiler-errors linked-list