```c
#include<stdio.h>
#include<stdbool.h>
#include<stdlib.h>
typedef struct _node{
int value;
struct _node *next;
}Node;
typedef struct _list{
Node* head;
//Node* tail;
}List;
void print(List* pList);
void add(List* pList,int number);
int main(int arge,char const *argv[])
{
List* list;
list=(List*)malloc(sizeof(struct _list));
int number;
list->head=(Node*)malloc(sizeof(struct _node));
list->head->next=NULL;
do{
scanf("%d",&number);
if(number!=-1){
/*list->head=*/add(list,number);
}
}while(number!=-1);
print(list);
return 0;
}
void add(List* pList,int number)
{
// add to linked-list
Node*p=new Node;
p->value=number;
p->next=NULL;
// find the last
Node *last=pList->head->next;
if(last){
while(last->next){
last=last->next;
}
// attach
last->next=p;
}else{
pList->head->next=p;
//这边改last就直接错了,不知道为啥???
}
}
void print(List* pList)
{
Node* p;
p=pList->head->next;
if(p){
while(p)
{
printf("%d",p->value);
p=p->next;
}
}else{
printf("只有一个结点%d喔!\n",p->value);
}
}
```