#include<stdio.h>
#include<stdlib.h>
void add(Node **phead, int number);
typedef struct _node{
int value;
struct _node* next;
}Node;
typedef struct list {
Node* head;
Node* tail;
}List;
int main()
{
Node* head = NULL;
int number;
do {
scanf_s("%d", &number);
if (number != -1) {
add(&head, number);
}
} while (number != -1);
for (Node*pi=head;pi->next!=NULL;pi=pi->next) {
printf("%d ", pi->value);
}
return 0;
}
void add(Node* *phead, int number)
{
Node* p = (Node*)malloc(sizeof(Node));
p->value = number;
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/686555885736135.png "#left")
p->next = NULL;
Node* last = *phead;
if (last) {
while (last->next) {
last = last->next;
}
last->next = p;
}
else {
*phead = p;
}
}
代码如上,问题在三行的声明(27行同样也过不去),课程里也是这样两个**,求解