sum (adding 2 numbers ) without plus operator

后端 未结 9 669
借酒劲吻你
借酒劲吻你 2021-02-05 20:42

Can anyone explain the logic how to add a and b?

#include 

int main()
{
     int a=30000, b=20, sum;
     char *p;
             


        
9条回答
  •  长发绾君心
    2021-02-05 21:30

    C standard says that E1[E2] is equivalent to *((E1) + (E2)). Therefore:

     &p[b] = &*((p) + (b)) = ((p) + (b)) = ((a) + (b)) = a + b
    

提交回复
热议问题