#include<stdio.h>
#include<stdlib.h>
struct Node
{
int data;
struct Node*next;
}
struct Node*createNode(int data)
{
struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
newNode->data=data;
newNode->next=NULL;
return newNode;
}
void insertByHead(struct Node**list, int data)
{
struct Node* newNode = createNode(data);
newNode->next = (*list);
(*list) = newNode;
}
void printList(struct Node*list)
{
struct Node*pMove = list;
while(pMove)
{
printf("%d\t",pMove->data);
pMove=pMove->next;
}
printf("\n");
}
int main()
{
struct Node*list = NULL;
insertByHead(&list,1);
insertByHead(&list,2);
insertByHead(&list,3);
printList(list);
system("pause");
return 0;
}