• edited by
1,199 views
1 1 vote
void main()

{

int *x;

x =f();

printf("%d", *x);

}

int *f()

{

int y = 7 ;

return &y;

}

1 Answer

0 0 votes
yes, ans is unexpexted because when function definition is completed then local variable of function will discard
Position:
Show:

Related questions

1 1 vote
1 answers 1 answer
1.4k
1.4k views
abhinowKatore asked Jan 18, 2023
1,432 views
What will be the output of the following program ?answer is 8 but I am getting 5, please explain where I am wrong
0 0 votes
1 1 answer
565
565 views
altamash asked Apr 12, 2019
565 views
int main();{int a,*b, c, *d, e;a=10;b=&a;c=&b;d=&c;e=&d;print f(“a=%d b=%u c=%u d=%u e=%u e=%u\n”, a,b,c,d,e);print f(“ %d %d %d \n”,a,a+*b, c+ *d+, e);return 0;}