C程序设计的#define? [英] C Programming #define?
本文介绍了C程序设计的#define?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:结果
<一href=\"http://stackoverflow.com/questions/949433/could-anyone-explain-these-undefined-behaviors-i-i-i-i-i-etc\">Could谁能解释这些不确定的行为,(I = I + + + + I,I = I ++等&hellip;)
块引用>#包括LT&;&stdio.h中GT;
#包括LT&;&CONIO.H GT;SQ的#define(X)X * X无效的主要()
{
INT A1,A2;
INT B1,B2; A1 = 2;
A2 = 2; B1 = 0;
B2 = 0; B1 = SQ(A1 +);
B2 = SQ(++ A2); 的printf(弗里斯特=%d个,B1);
的printf(第二=%d个,B2);
}我知道了什么是code的输出。
在其他PROGRAME的#define工作
这样,它不高于code工作
为什么?解决方案与多个++在同一个变量运营商的前pression的结果是正式在未定义行为温度。
Possible Duplicate:
Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc…)
#include<stdio.h> #include<conio.h> #define SQ(x) x*x void main() { int a1 , a2; int b1 , b2; a1 = 2; a2 = 2; b1 = 0; b2 = 0; b1 = SQ(a1++); b2 = SQ(++a2); printf("Frist = %d",b1); printf("Second = %d",b2); }
I know what is the output of the code.
as #define work in other programe that way it is not working in above code Why.?
解决方案The result of an expression with more than one ++ operator on the same variable is officially an undefined behavior in C.
这篇关于C程序设计的#define?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文