tangsir
V2EX  ›  问与答

求助 c 语言链表,我哪里错了, vc++6.0 好弱智不显示行号

  •  
  •   tangsir · Dec 13, 2015 · 1394 views
    This topic created in 3836 days ago, the information mentioned may be changed or developed.

    include <stdio.h>

    include <malloc.h>

    include <stdlib.h>

    struct Node
    {
    int data;
    struct Node * pNext;
    };

    struct Node *creat_list(void);
    void traverse_list(struct Node *);

    int main(viod)
    {
    struct Node * pHead = NULL;

    pHead = creat_list();
    traverse_list(pHead);
    
    return 0;
    

    }

    struct Node * creat_list()
    {
    int i;
    int val;
    int length;

    printf("请输入链表长度:");
    scanf("d%",&length);
    
    struct Node * pHead = (struct Node *)malloc(sizeof(struct Node)) ;
    struct Node * pTail = pHead;
    pTail->Next = NULL;//分配一个空头文件完成,尾部指向为空
    
    for (i=0;i<length;++i)
    {
        printf("请输入第 d%节点",i+1);
        scanf("d%",&val);
    
        struct Node * pNew = (struct Node *)malloc(sizeof(struct Node));
        if(pNew == NULL)
        {   printf("分配失败,程序终止!");
            exit(-1);
        }
    
        pNew->data = val;
        pTail->data = pNew->data;
        pTail->pNext =NULL;
    
    }   
    
    traverse_list(pHead);
    {
        struct Node * p = pHead->pNext;
        while (pNew == NULL)
        {
            printf("节点为 dd%",p->data);
            p = p->pNext;
        }
    
        return;
    }
    

    }

    comicfans44
        1
    comicfans44  
       Dec 14, 2015
    struct Node * p = pHead->pNext;
    while (pNew == NULL) -------------------------------> ???
    {
    printf("节点为 dd%",p->data);
    p = p->pNext;
    }
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3317 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 12:06 · PVG 20:06 · LAX 05:06 · JFK 08:06
    ♥ Do have faith in what you're doing.