在C语言中的前pression(3 ^ 6)+(A ^ A)的输出? [英] Output of the expression (3^6)+(a^a) in C language?
问题描述
我是一个业余的C程序员,我在一本书中遇到这个问题,能有人给我了合理的解释。
我越来越困惑,这是什么^标志是在C程序做的。
的#include<&stdio.h中GT;INT主要(无效)
{
int类型的;
的printf(%d个,(3 ^ 6)+(A ^ A));
返回0;
}
int类型的;
的printf(%d个,(3 ^ 6)+(A ^ A));
在(3 ^ 6)+(A ^ A)
前presion公司调用未定义行为为 A $的评估C $ C>没有初始化,有一个不确定的值。
(C11,6.3.2.1p2)如果左值指定,可能已被宣布为寄存器存储类自动存储持续时间的对象(从来没有考虑它的地址),以及对象初始化(不带声明初始化并没有分配给它之前已经进行使用),则该行为是不确定的。
块引用>I am an amateur C programmer and I encountered this question in a book,can someone give me its valid explanation. I am getting confused as to what this ^ sign is doing in a C program.
#include <stdio.h> int main(void) { int a; printf("%d", (3^6) + (a^a)); return 0; }
解决方案int a; printf("%d",(3^6)+(a^a));
The evaluation of the
(3^6)+(a^a)
expresion invokes undefined behavior asa
is not initialized and has an indeterminate value.(C11, 6.3.2.1p2) "If the lvalue designates an object of automatic storage duration that could have been declared with the register storage class (never had its address taken), and that object is uninitialized (not declared with an initializer and no assignment to it has been performed prior to use), the behavior is undefined."
这篇关于在C语言中的前pression(3 ^ 6)+(A ^ A)的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!