C/C++教程

C:多级指针

本文主要是介绍C:多级指针,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

C:多级指针

 

/*
*    os = Linux openeuler 4.19.90-2106.3.0.0095.oe1.x86_64
*    gcc_version = gcc version 7.3.0 (GCC)
*    file_name = pointer_test.c
*    gcc   -o  pointer_test  pointer_test.c
*
*/ 

#include <stdio.h>

typedef struct _people
{
        int id;
        int age;
} people, *people_pt, person, *person_pt;


// test pointer
int main(int argc, char** argv)
{
        int x=13;

        int *pt1 = NULL;
        int **pt2 = NULL;
        int ***pt3 = NULL;
        int ****pt4 = NULL;
        int *****pt5 = NULL;
        int ******pt6 = NULL;


        pt1 = &x;
        pt2 = &pt1;
        pt3 = &pt2;
        pt4 = &pt3;
        pt5 = &pt4;
        pt6 = &pt5;

        printf("pt1=%p, *pt1=%d .\n", pt1, *pt1);
        printf("pt2=%p, *pt2=%p .\n", pt2, *pt2);
        printf("pt3=%p, *pt3=%p .\n", pt3, *pt3);
        printf("pt4=%p, *pt4=%p .\n", pt4, *pt4);
        printf("pt5=%p, *pt5=%p .\n", pt5, *pt5);
        printf("pt6=%p, *pt6=%p .\n", pt6, *pt6);
        printf("pt6=%p, ******pt6=%d .\n", pt6, ******pt6);


        return 0;
}

  

这篇关于C:多级指针的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!