简体   繁体   中英

Can anyone explain output

#define power(a) #a
  int main()
  {
    printf("%d",*power(432));
     return 0;
  }

can anyone explain the o/p??
the o/p is

52

It is equivalent to:

printf("%d",*"432");

which is equivalent to:

printf("%d", '4');

and the ASCII value of '4' is 52 .

#define power(a) #a   //# is a stringization operation in macro
  int main()
  {
    printf("%d",*power(432));
     return 0;
  }

Hence after calling power(432), macro will return it "432" and applying * on it gives first value which is nothing but 52 (48 + 4) for '4' . 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM