In C,why is multiple declarations working fine for a global variable but not for a local variable?

In C and C++, int y; within a function is both a declaration and a definition.

In C, int x; in the file scope (outside any function) is a declaration and a tentative defintion. Multiple tentative definitions are allowed; only one definition is allowed.

Leave a Comment