Variable declaration and definition

前端 未结 2 785
醉酒成梦
醉酒成梦 2021-01-06 18:56
int x;

Is this a declaration or a definition?

As I write the following code,

#include 

int main(void)
{
            


        
2条回答
  •  隐瞒了意图╮
    2021-01-06 19:24

    int x; is a definition. extern int x; is just a declaration. extern int x = 3; is also a definition. HTH

提交回复
热议问题