Suppose I have a static variable declared inside a function in C.
If I call this function several times, does the static variable get reallocated in memory every time the function is called?
If it is redistributed, why is the last value always supported?
Example:
void add()
{
static int x = 1;
x++;
printf("%d\n",x);
}
int main()
{
add();
add();
add();
}
source
share