2013-03-02 167 views
4
#define power(a) #a 
    int main() 
    { 
    printf("%d",*power(432)); 
    return 0; 
    } 

任何人都可以解释o/p?
the o/p is任何人都可以解释输出

+3

您认为它有什么作用?你有没有努力理解这个代码?这是微不足道的。 – 2013-03-02 14:13:52

+0

我不明白'*'是什么? – akash 2013-03-02 14:17:24

+2

在这种情况下,您最需要阅读基本的C语言教程。它用于指针取消引用。 – 2013-03-02 14:17:53

回答

12

它等效于:

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

这相当于:

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

'4' ASCII值是52

0
#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' . 
相关问题