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

  • 相关阅读:
    网站测试
    shell102输出数组
    shell101变量
    shell100for无参数形式
    shell99函数中传数组
    shell98函数的参数
    将php中session存入redis中
    windows下安装redis客户端
    window下phpstudy开启redis扩展
    *ginx下开启phpredis扩展
  • 原文地址:https://www.cnblogs.com/ijpq/p/15428297.html
Copyright © 2011-2022 走看看