小编Kha*_*led的帖子

LinkedList打印相同的值

我目前正在学习C,但是我面对的是链表,这种情况我真的不明白。

我创建了以下程序:

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

struct list
{
    int age;
    char name[256];
    struct list *next;
};

void displayList ( struct list *node );

int main( void )
{
    struct list *node = malloc ( sizeof ( struct list ) );

    node->age = 10;
    strcpy( node->name, "Kiara" );

    node->next = malloc ( sizeof ( struct list ) );
    node->next->next = NULL;

    displayList( node );

    free( node->next );
    free( node );
}

void displayList ( struct list *node ) …
Run Code Online (Sandbox Code Playgroud)

c linked-list

3
推荐指数
1
解决办法
76
查看次数

标签 统计

c ×1

linked-list ×1