请大家帮我看看这个简单操作
#include <stdio.h>#include <malloc.h>
#include <stdlib.h>
typedef struct LNode
{
int num;
int passwd;
struct LNode *next;
struct LNode *prior;
}LNode;
void Creat(LNode *L,int n)
{
LNode *p,*q;
int i = 0;
L = p = q = NULL;
for(i = 1;i <= n;i++)
{
p = (LNode *)malloc(sizeof(LNode));
scanf("%d",&p->passwd);
p->num = i;
if(L == NULL)
{
L = q = p;
}
else
{
q->next = p;
p->prior = q;
q = p;
}
}
p->next = L;
L->prior = p;
}
void Print(LNode *L)
{
LNode *p;
p = L;
printf("%d ",p->passwd);
p = p->next;
while(p != L)
{
printf("%d ",p->passwd);
p = p->next;
}
}
void main()
{
LNode L;
int n , m ;
scanf("%d%d",&m,&n);
Creat(&L,n);
Print(&L);
}
我在主函数中将节点地址传入,为什么不能成功创建 我调试的时候发现打印的p->passwd是乱码