Static variables are stored in data segment of program unlike auto variables which are stored in stack section. Suppose I write code like below.
#include <stdio.h>
void temp();
int main()
{
static int a=10;
temp();
return 0;
}
void temp()
{
static int a=20;
}
Where same static variable name is defined in 2 functions. In data segment layout there will be 2 variables with same name. Does n't this make confusion at compile/execution time? how this is avoided currently?