Will a value live perpetually when there's no reference to it?

前端 未结 8 1276
鱼传尺愫
鱼传尺愫 2021-02-13 07:02

Suppose the following minimal code:

#include 
char character = \'c\';
int main (void)
{
    char character = \'b\';
    printf(\"The current value         


        
8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-13 07:49

    Although global variables exist from the start to the end of the execution of a program, they are not automatically accessible.

    A global variable is accessible starting from the location in the file where the global variable is defined or declared until the end of the file.

    If in a function scope one defines a variable with the same name, the global variable will exist, but will not be accessible.

提交回复
热议问题