main(){
int *j;
{
int i=10;
j=&i;
}
printf(”%d”,*j);
}
Answer:
10
The variable i is a block level variable and the visibility is inside that block only. But the lifetime of i is lifetime of the function so it lives upto the exit of main function. Since the i is still allocated space, *j prints the value stored in i since j points i.
Lifetime and visibility of a variable
October 6th, 2006 · No Comments · C/C++
Tags:
















0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment