1. 程式人生 > >日常出錯!求大佬幫解

日常出錯!求大佬幫解

#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);
}

輸入字元後按回車,進入無限迴圈。