zoukankan      html  css  js  c++  java
  • Algorithm for understanding pointer in C

    1. find the variable name
    2. translate the operator adjacent to the var name with prioirty
    3. translate anthor symbol adjacent to the var in the opposite direction
    4. go back to step 2
    5. finally, deal with the class declarition such as int and so forth
    // only a * on the left side adjacent to p, there is no symbol on the right side
    int *p // 1
    
    // * on the left side, [] on the right side. but [] is prior to *.
    // the order is p -> p[13] -> int *(p[13])
    int *p[13] // 2
    
    // this order is constrant by ()
    int *(p[13]) // 3
    
    // p -> *p -> int * *p
    int **p // 4 
    
    
    int (*p)[13] // 5
    
    // () is prior to *
    // f is a function which returns a pointer to int
    // f -> f() -> int *(f())
    int *f() // 6
    
    // f is a pointer for the priority of *
    // and then, the pointer point to function
    // f -> *f -> *f() -> int (*f())
    int (*f)() // 7
    
    // f is a function which returns a pointer.
    // the pointer point to a array of 13 elements.
    // each element is a pointer which point to a function which return int.
    int (*(*f())[13])() // 8
    
    // x is a array of which each is a pointer.
    // the pointer point to a function which return pointer
    // that point to a array of int
    int (*(*x[3])())[5] // 9
    

    other refs

  • 相关阅读:
    接口的幂等性原则
    SpringBoot热部署-解决方案
    @Resource 与 @Service注解的区别
    软件概要设计做什么,怎么做
    First Show
    Glide源码解析一,初始化
    android使用giflib加载gif
    android的APT技术
    RxJava的concat操作符
    RxJava基本使用
  • 原文地址:https://www.cnblogs.com/ijpq/p/15428297.html
Copyright © 2011-2022 走看看