Pointer operations and operator precedence in C

后端 未结 6 824
野性不改
野性不改 2021-02-04 03:32

Background

Just had a chat with a C guy today and we disagreed on the following:

int intgA[2] = { 1, 2 };
int intgB[2] = { 3, 5 };

int *intAPtr = intg         


        
6条回答
  •  故里飘歌
    2021-02-04 04:14

    I agree with John Bode answer to simplify it a bit I will just write it in code:

       *intAptr = * intBPtr;
    

    is equal to:

       *intAptr =*intBPtr 
       intAPtr+=1;
       inrBPtr+=1;
    

    so what we get is: intAPtr points to 2 intBPtr points to 5

提交回复
热议问题