新手求助,关于链表问题
#include<string.h>
#include<ctype.h>
#include<malloc.h>
#include<limits.h>
#include<stdio.h>
#include<stdlib.h>
#include<io.h>
#include<math.h>
#include<process.h>
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
typedef int Status;
typedef int Boolean;
typedef int ElemType;
#include <stdio.h>
#include <stdlib.h>
struct LNode
{
ElemType data;
LNode *next;
};
typedef LNode *LinkList;
void CreateList_L(LinkList &L,int n){
L=(LinkList)malloc(sizeof(LNode));
L->next=NULL;
for(int i=n;i>0;--i){
p=(LinkList)malloc(sizeof(LNode));
scanf(&p->data);
p->next=L->next;L->next=p;
}
}
int main()
{
LinkList L;
CreateList_L(L,2);
m=L->next;
while(m)
{
printf("%d\n",p->data);
p=p->next;
}
}
VC6.0中报错:--------------------Configuration: 1 - Win32 Debug--------------------
Compiling...
1.cpp
C:\Documents and Settings\Administrator\桌面\1.cpp(34) : error C2065: 'p' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\1.cpp(34) : error C2440: '=' : cannot convert from 'struct LNode *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\Documents and Settings\Administrator\桌面\1.cpp(35) : error C2227: left of '->data' must point to class/struct/union
C:\Documents and Settings\Administrator\桌面\1.cpp(36) : error C2227: left of '->next' must point to class/struct/union
C:\Documents and Settings\Administrator\桌面\1.cpp(36) : error C2440: '=' : cannot convert from 'int' to 'struct LNode *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\Documents and Settings\Administrator\桌面\1.cpp(44) : error C2065: 'm' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\1.cpp(44) : error C2440: '=' : cannot convert from 'struct LNode *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\Documents and Settings\Administrator\桌面\1.cpp(47) : error C2227: left of '->data' must point to class/struct/union
C:\Documents and Settings\Administrator\桌面\1.cpp(48) : error C2227: left of '->next' must point to class/struct/union
C:\Documents and Settings\Administrator\桌面\1.cpp(50) : warning C4508: 'main' : function should return a value; 'void' return type assumed
执行 cl.exe 时出错.
1.obj - 1 error(s), 0 warning(s)
请问怎么解决???