vi撤销命令(u):撤销上一次的操作
1 #include<stdio.h>
2 #include<stdlib.h>
3
4 struct test
5 {
6 int data;
7 struct test *next;
8 };
9
10 void printLink(struct test *head)
11 {
12 struct test *point = head;
13 while(point !=NULL ){
14 printf("%d ",point->data);
15 point = point->next;
16 }
17 putchar('\n');
18 }
19
20 struct test* insertFromHead(struct test *head)
21 {
22 while(1){
23 struct test *new =(struct test*)malloc(sizeof(struct test*));
24 printf("please input a new \n");
25 scanf("%d",&(new->data));
26 if(new->data==0){
27 return head;
28 }
29 else if(head==NULL){
30 head = new;
31 }else{
32 new->next=head;
33 head=new;
34 }
35 }
36 }
37
38 int main()
39 {
40 struct test *head=NULL;
41 head = insertFromHead(head);
42 printf("result:\n");
43 printLink(head);
44 return 0;
45 }