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

前端 未结 8 1440
鱼传尺愫
鱼传尺愫 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条回答
  •  萌比男神i
    2021-02-13 07:37

    Normaly, the global variable will stay. Since your local variable only shadows the name, it doesn't affect the storage.

    But it could also depend on linker settings. Linker could optimize the unsused global variable out.

提交回复
热议问题