这个程序为什么不对呢,无显示的.......
#include "stdlib.h"
#include "stdio.h"
#include "conio.h"
#define N 5
#define LEN sizeof(struct list)
#define NULL 0
struct list
{
float data;
struct list *next;
};
void main()
{
struct list *head;
struct list *p1,*p2;
struct list *p;
int n;
n=0;
p1=p2=(struct list *)malloc(LEN);
printf("please input the first data:");
scanf("%f",&p1->data);
head=NULL;
while(n<N)
{
n++;
if(n==1)
head=p1;
else
p2->next=p1;
p2=p1;
p1=(struct list *)malloc(LEN);
printf("please input the next data:");
scanf("%f",&p1->data);
}
p2->next=NULL;
p=head;
for(n=0;n<N-1;n++)
{
printf("%f->",p->data);
p=p->next;
}
}