我是新来的,很抱歉没有提供我应该获得帮助的所有信息,但这里是。
struct node {
int data;
struct node* next;
struct node* previous;
};
*currentB = MultByTen(*currentB); // this is a line in another function.
// currentB is a struct node with data it in.
struct node* MultByTen(struct node* current) {
struct node *newNode = malloc(sizeof (struct node));
newNode->data = 0;
newNode->next = NULL;
while (current->next != NULL) {
current = current->next;
}
newNode->previous = current;
current->next = newNode;
return current;
}
从我旁边有注释的那一行代码中,我收到“错误:从类型'int'分配给类型'struct node'时不兼容的类型”。我正在返回一个 struct node* 所以我不知道为什么会出现这个错误。有任何想法吗?
-编辑:currentB 是一个链接列表,其中包含数据。它是
struct node* currentB = malloc(sizeof(struct node));
出于示例的目的,它是 1->2->3->4->NULL ,我想要 MultByTen 只是在列表的末尾添加一个 0 ,这样它就会变成 1->2->3 ->4->0->NULL