Static variables
In this code :
#include
int same(int);
main()
{
printf("first time ...same(1) ...returns ..%d\n",same(1));
printf("second time ...same(2) ...returns ..%d\n",same(2));
}
int same(int k)
{
int x=k;
static int y=x;
return y;
}
On compiling this using a C compiler,
gives an error :
non-constant initializer: op "NAME"
Guess this has to do with initialization of
the static vars during definition
Try in solving this.
AnswerU cannot assign x to y (which is a static variable).You can only assign constant value to static variables.
A very good site on C programming is www.aquaphoenix.com/ref/gnu_C_library/