zoukankan      html  css  js  c++  java
  • 指针的基本知识点

    #include<stdio.h>
    
    void A(int *c)
    {//c存的是cntptr存储的地址 
        int b=4;
        c = &b;//改变的只是c的指向,主函数的值不受影响 
    }
    void B(int *c)
    {//c存的是cntptr存储的地址 ,指向cntptr指向的地址 
        int b=8;
        *c = b;//改变指向地址存的值 
    }
    int main()
    {
        int count = 5,*cntptr = NULL;
        cntptr = &count;
        printf("调用函数前
    ");
        printf("count的地址%p
    ",&count);//实际地址取决于所用的机器,编译器,操作系统 
        printf("cntptr的值%p
    ",cntptr);
        A(cntptr);//该函数改变的只是形参的指向 
        printf("调用函数后
    ");
        printf("count的地址%p
    ",&count);//实际地址取决于所用的机器,编译器,操作系统 
        printf("cntptr的值%p
    ",cntptr);
    
        printf("调用函数前
    ");
        printf("count的值:%d
    ",count);
        printf("*cntptr的值:%d
    ",*cntptr);
        B(cntptr);//该函数改变的是形参指向的地址所储存的值 
        printf("调用函数后
    ");
        printf("count的值:%d
    ",count);
        printf("*cntptr的值:%d
    ",*cntptr);
        *cntptr = 10;
        printf("count的值:%d
    ",count);
        printf("*cntptr的值:%d
    ",*cntptr);
        return 0;
    }

    指针自己没学好 所以现在一边学数据结构一边复习指针

  • 相关阅读:
    Java Web学习笔记3
    Java学习笔记11
    diff 比较两个文件的差异
    Java学习笔记10
    appium——如何导出夜神模拟器下载“微信”app的apk
    python之文件操作模块(os和shutil)
    浅谈HTTP和HTTPS
    LUNIX命令集
    ubuntu软件管理工具的使用——dpkg和apt
    CSS学习—day1
  • 原文地址:https://www.cnblogs.com/hellocheng/p/7350146.html
Copyright © 2011-2022 走看看