我们如何确定 'b' 的值在这段代码的开头是 0

How can we be sure that value of 'b' is 0 at beginning in this code

这是我在网上看到的一个计算</code>的值的程序。</p> <pre><code>#include <stdlib.h> #include <stdio.h> long a=10000,b,c=2800,d,e,f[2801],g;//--------HERE the value of b---------// int main() { printf("\nValue of b: %ld", b); getch(); for(;b-c;) f[b++]=a/5; for(;d=0,g=c*2;c-=14,printf("%.4d",e+d/a),e=d%a) for(b=c;d+=f[b]*a,f[b]=d%--g,d/=g--,--b;d*=b); }

计算值正确。但是程序员怎么能确定 b 的初始值是 0 呢?

好像根本没有初始化!

全局变量的初值有什么特殊性吗?

正如this问题中指出的,全局变量默认初始化为0

在您的代码中,b 被声明为全局变量。