close

 

compiler解析 printf("%d\n%d\n%d\n",++*p,*++p,*p++)

是由右到左

step 1:

x[0] x[1] x[2] x[3] x[4]

  0   10   20   30   40

  P

*p++

先印*p 再移動p 印出 0


step 2:

x[0] x[1] x[2] x[3] x[4]

  0   10   20   30   40

        P

*++p


x[0] x[1] x[2] x[3] x[4]

  0   10   20   30   40

               P

先++p 再印出*p


step 3:

x[0] x[1] x[2] x[3] x[4]

  0   10   20   30   40

              P

++*p

先++*p的值 再印出


所以會印出 0 20 21


因為compiler不同也會有所差異

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 flyinsky76 的頭像
    flyinsky76

    Deja Vu

    flyinsky76 發表在 痞客邦 留言(0) 人氣()