主题:链表编译失败,求高手
#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;
}
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;
}