链表使用简述

2023-12-16 19:30:26
#include <stdio.h>
#include <stdlib.h>




typedef struct Node {

    char* name;
    int height;
    struct Node* next;
} Node;

void assine(Node*);

int main()
{
    Node first_node; Node second_node;
    first_node.name = "yunling"; 
    first_node.height = 21; 
    first_node.next = NULL;

    printf("数据:first_node.height=%d\n", first_node.height);
    printf("地址:first_node=%p,first_node->next=%p\n", &first_node, first_node.next);      

    assine(&first_node);

    printf("数据:first_node.height=%d\n", first_node.height);
    printf("地址:first_node=%p,first_node->next=%p\n", &first_node, first_node.next);
    
    return 0;
}

void assine(Node* first_node) 
{
    Node second_node;
    second_node.name = "lixiangcheng"; second_node.height = 70; second_node.next = NULL;
    first_node->height = 33;
    first_node->next = &second_node;
}

文章来源:https://blog.csdn.net/weixin_46855342/article/details/135036072
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。