Strange C language statement

zhaozj2021-02-16  101

Everyone knows that the change of the variable is a very common, obvious error, but actually found that the following code can be compiled in the C environment in one discussion of Shuishui, and it is very good. code show as below:

? #include "stdio.h" #include "stdlib.h" INT i; int i; = 100;? int main () {? ??? printf ("% d / n", i);??? System ("pause"); ?????? Return 0;} Is there no second meaning? So I should have the following code, becoming:

? #include "stdio.h" #include "stdlib.h" INT i; int 1; I ; int main () {? ??? printf ("% d / n", i); ?? ? system ("pause"); ???? Return 0;} If I want, I really have an error. But if you move them into the main function, the result is not too the same,

? #include "stdio.h" #include "stdlib.h" INT i; int = = 100; ??? i ; ??? printf ("% d / n" i); ??? system ("pause"); ??? Return 0;} Obviously, I has been unique before entering main, after a friend's reminder I think that early C definition can be used as a statement Used, this historical problem is sometimes troublesome, so a good program design style is too important.

转载请注明原文地址:https://www.9cbs.com/read-10657.html

New Post(0)