#include "stdio.h"
#include "conio.h"
#include "stdlib.h"
#include "alloc.h"
typedef struct node
{
int data;
struct node *next;
}NODE;
main()
{
NODE *head=NULL,*q;
int i;
for(i=0;i<10;i++)
{
q=(NODE*)malloc(sizeof(NODE));
scanf("%d",&q->data);
q->next=head;//从表头插入节点
head=q;
}
printf("链表遍历\n");
q=head;
while(q!=NULL)
{if(q->next!=NULL)
printf("%d->",q->data);
else
printf("%d",q->data);
q=q->next;
}
getch();//输入代码
}
显示如下——
\Documents and Settings\Administrator\My Documents\link.c C:\Documents and Settings\Administrator\My Documents\C alloc.h: No such file or directory.