日常出错!求大佬帮解

#include<stdio.h>
#include<string.h>

typedef struct node
{
    char data;
    struct node *next;
}lnode;

void creat_linklist(lnode **head)
{
    char x;
    lnode *p;
    (*head)=(lnode *)malloc(sizeof(lnode));
    (*head)->next=NULL;
    printf("请输入字符信息\n");
    scanf("&c",&x);
    while(x!='\n')
       {
           p=(lnode *)malloc(sizeof(lnode));
           p->data=x;
           p->next=(*head)->next;
           (*head)->next=p;
           printf("success\n");
           scanf("%d",&x);

       }
}

int main()
{
    lnode *p;
    creat_linklist(&p);
}

输入字符后按回车,进入无限循环。

猜你喜欢

转载自blog.csdn.net/cruel2436/article/details/82817175