T
the_init
Hi friends,
Can you please explain me why the following code prints 10, instead of
20 - Here I am little confused with the static and global declaration
of i in the same program.
#include<stdio.h>
int i;
int foo();
int print();
int main(void)
{
i = 10;
foo();
return 0;
}
int foo()
{
static int i = 20;
print();
return 0;
}
int print()
{
printf("%d", i);
return 0;
}
Can you please explain me why the following code prints 10, instead of
20 - Here I am little confused with the static and global declaration
of i in the same program.
#include<stdio.h>
int i;
int foo();
int print();
int main(void)
{
i = 10;
foo();
return 0;
}
int foo()
{
static int i = 20;
print();
return 0;
}
int print()
{
printf("%d", i);
return 0;
}