zoukankan      html  css  js  c++  java
  • 指针符号的优先级

    #include <stdio.h>
    #include <stdlib.h>
    
    struct i2c_dev
    {
        int fd;
        int addr;
    };
    
    static struct i2c_dev  i2c[3];
    static struct i2c_dev* pi2c;
    
    int main()
    {
    
        pi2c = &i2c[1];
        i2c[1].fd = 0x02;
        printf("i2c_dev  fd is %d
    ",++pi2c->fd);  // 3 
    
        printf("i2c_dev  fd is %d
    ",pi2c++->fd);  // 3 
    
    
        return 0;
    }
    #include <stdio.h>
    #include <stdlib.h>
    
    struct stu
    {
        int x;
        int *y;
    };
    
    struct stu*p;
    
    int dt[4] = {10,20,30,40};
    struct stu a[4] = {50,&dt[0],60,&dt[1],70,&dt[2],80,&dt[3]};
    
    int main()
    {
    
        p = a;
        printf("%d,",++p->x);     // 51 
        printf("%d,",(++p)->x);   // 60 
        printf("%d
    ",++(*p->y)); // 21    // -> 这个优先级 比较高
    
    
        return 0;
    }
    一勤天下无难事。
  • 相关阅读:
    @atcoder
    @loj
    @atcoder
    @gym
    @codeforces
    @atcoder
    @bzoj
    @loj
    Kafka常用命令
    Kafka入门介绍
  • 原文地址:https://www.cnblogs.com/nowroot/p/15365989.html
Copyright © 2011-2022 走看看