Scope of a variable outside main in C

前端 未结 7 604
深忆病人
深忆病人 2020-12-15 21:41

Consider the code:

#include 

int x;

int main (void) 
{ }

The value of x is 0 inside main

7条回答
  •  隐瞒了意图╮
    2020-12-15 22:25

    Your compiler initialized the value of x to be 0.

    It's a global variable which is visible from within main()

提交回复
热议问题