Answer on Question# 52642, Programming, C
In C, which of the following variables are created at the time of a function call and destroyed when the function returns?
(a) integer variables
(b) parameters to the function
(c) static variables declared within the function
(d) extern variable
Answer: a
Integer variables are created at the time of a function call and destroyed when the function returns.
Parameters of the function can be described as reference, in this case memory, which set for memory can be removed in another part of program.
static int myStaticVar = 0;Static- static variable. Life time - constant. Initialized once at the first performance of the operator, containing the definition of the variable. So, this type of variables didn't destroyed after return function.
Extern- means that the variable is defined anywhere else the program (in another file or further in the text). It is used to create variables that are available in all modules of the program in which they are declared. So, this type of variables didn't destroyed after return function.
Comments