少有人走的路

勇哥的工业自动化技术网站

python知识导航贴,持续更新

C# 语言高级特性知识导航贴,持续更新

netMarketing类库: 类库说明

本站视觉相关教程整理贴子,持续更新

C++相关导航贴,持续更新

本站收费服务公告(netMarketing源码,工业自动化行业培训班等)

2020年勇哥的机器视觉实验项目清单(大纲)

本站连载贴子系列,持续更新中……

勇哥的免费视频教程清单

勇哥在B站发布的视频清单

运动控制专题,持续更新

windows驱动编程学习(二)基础知识回顾之指针

勇哥注:

指针练习好了,能解决90%的驱动开发时遇到的各种问题。



#include<stdio.h>
typedef void(*p_fun)(int i, int j);
struct st {
    int i;
    int j;
    int b;
    p_fun p_fun1;
};

void fun(int i, int j) {
    printf("fun%d %d\n", i, j);
}

int main()
{
    struct st st_ = { 0 };
    st_.i = 1;
    st_.j = 2;
    st_.p_fun1 = fun;
    st_.p_fun1(1, 2);     //fun1 2
    printf("%p %p\n", st_.p_fun1, &st_.p_fun1);    //00007FF668281334   000000496FF2F5A8

    struct st* pst_;
    pst_ = &st_;
    printf("%d %d\n", st_.i, st_.j);      //1  2

    int* p_int = (int*)pst_;
    printf("+0 %d %p\n", *p_int, p_int);  //   1   0000001B7CB2F4F8
    //*p_int=1;
    p_int += 1;
    printf("+1 %d %p\n", *p_int, p_int);  //+1  2   0000001B7CB2F4FC
    //*p_int=2;
    
    p_int += 1;
    *p_int = 3;
    printf("+1 %d %p\n", *p_int, p_int);  //+1   3  0000001B7CB2F500
 
    p_int += 1;
    printf("+1 %d %p\n", *p_int, p_int);   //+1   0   0000001B7CB2F504

    p_int += 1;
    printf("+1 %p %p %p\n", *p_int, p_int, *(long long int*)p_int);   //+1 0000000068281334 000000496FF2F5A8 00007FF668281334

   
    p_fun p =(p_fun)(*(long long int*)p_int);
    printf("%p\n",p);           //00007FF65AF91334
   
    p(1, 2);                  //fun1 2

    (*(p_fun*)p_int)(2, 3);   //fun2 3

    printf("%lld\n", sizeof(struct st));    //24

    return 0;
  
}
<< 1 >>
«    2024年7月    »
1234567
891011121314
15161718192021
22232425262728
293031
控制面板
您好,欢迎到访网站!
  查看权限
网站分类
搜索
最新留言
文章归档
网站收藏
友情链接

Powered By Z-BlogPHP 1.7.3

Copyright www.skcircle.com Rights Reserved.

鄂ICP备18008319号


站长QQ:496103864 微信:abc496103864