链表的程序编译失败,拜求高手解疑, 编译器是VC++ 6.0
#include "stdio.h"typedef struct LNode
{
int key;
struct LNode * nextptr;
} LNode, * LinkList;
int main()
{
int n = 3;
int i;
LinkList L;
LinkList p;
L = ( LinkList ) malloc ( sizeof ( LNode ) );
L -> nextptr = NULL;
for ( i = 1; i <= n; i ++ )
{
p = ( LinkList ) malloc ( sizeof ( LNode ) );
scanf ( "%d", & p -> key );
p -> nextptr = L -> nextptr;
L -> nextptr = p;
}
p = L -> nextptr;
while ( p )
{
printf ( "\n%d", p -> key ) ;
p = p -> nextptr;
}
getch();
return 0;
}