Query on the scope of local variables in C
- by darkie15
All,
Consider the following code:
void func(void)
{
int a;
printf ("%d", a);
}
int main(int argc, char **argv)
{
int a = 3;
func();
printf("%d", a);
}
According to my understanding, the output should be:
<junk value><3>
Can anyone please confirm my understanding? My basic query is, does the compiler refer to the outer scope for a variable that has been declared but not defined?
Regards,
darkie