int *call();
void main()
{
int *ptr;
ptr=call();
clrscr();
printf("%d",*ptr);
}
int * call()
{
int x=25;
++x;
return &x;
}
The above program will give garbage value as output, bcoz the X is local variable & its scope is over, to correct this problem you can make X as static variable.
No comments:
Post a Comment