Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Use static local shaping variables in custom functions to calculate the cubic value of 3.
Use static local shaping variables in custom functions to calculate the cubic value of 3.
int iTemp

iTemp = iSum

This can be omitted directly and changed to static intisum = 3; iSum = iSum * 3; I will change your program code as follows: # include

{

Static intisum = 3; iSum = iSum * 3;

printf("%d\n ",iSum);

}

int main()

{

calculate();

calculate();

Returns 0;

}-.So the life cycle of his variable is the running period of the whole program. Therefore, after the function is completed, his life cycle will not end, that is, the memory will not be released. When this function is completed for the first time, the value of the iSum variable will become 9. When the function ends, its value is still 9. When performing this function for the second time, iSum=iSum*3 iSum=9*3=27. So, the result will be like this.