1) I have read about the undefined behavior in C several times. It is about this: Some behaviors that are not in C are defined, so each compiler will implement them but not violate the C standard. Examples are: But can anyone here give me two compilers who can give different results? I'm interested in testing with it. (In my machine, I am just mingueway) 2) And, C According to the following example: If we have: However, But, almost all about C Books, All People Coding C, Always Use: Please explain me about this point. Thanks :) You have been given an undefined behavior; You feel that the result of undefined behavior is unheard of Practical behaviors, i.e., the vibrator has chosen one of the different possibilities, which is often something that you can live with. The undefined behavior can be very bad. If the behavior is undefined then the compiler Usually can choose anything for your liking, eat your lunch, free up your bank account, and crash your computer. And unfortunately there are situations where Plug not shove will those bad things that you do not expect these Ukbik the first place. x = ++ y * 4 +++ y * 3 .
+ - * / does not say about the order of operation. For example:
1 * 2 + 3 + 4 * 5 .
* / will be calculated first, but we do not know the second.
int a, b, c; // a, b, c Specify the value for float = a * b / c; // wrong float result = (float) a * b / c; // seems correct
b / c can still be calculated first, so the answer is wrong. Therefore, the right type artist should be:
Float result = a * b / (float) c
(float) a * b / c . Is it always true, or do they believe "normal compiler" from left to right, just like we would often think?
Comments
Post a Comment