Hello to everyone. I found that a static or global variable will lose its "power" if you assign a value after initialization. Here is an example
For instance I have had trials on the above code that is why I have "//" on the third line.
int foo(int x , int y);
int i , j;
for(i=0 , j=5; i<5; i++ , j++)
printf(" The addition of %d and %d is %d. \n \n" , i , j , foo(i,j));
int foo(int x , int y)
static int c=1;
printf(" This is the call of the function : %d \n " , c++);
return x+y ;
The output of c variable is 2 , 2 , 2 , 2 , 2
not 2 , 3 , 4 , 5 , 6
If I reject the line c=2;
the output of c variable will be 1 , 2 , 3 , 4 , 5.
My question is... what is happen? The assignment c=2 after initialization has the power to "destroy" a static nature of a variable as we can see?
THank you in advance.