retagged by
2,586 views
0 votes
0 votes

What is the output of this C code? Please explain what is happening at line no. 12

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 97, *p = &i;
  5.         foo(&p);
  6.         printf("%d ", *p);
  7.         return 0;
  8.     }
  9.     void foo(int **p)
  10.     {
  11.         int j = 2;
  12.         *p = &j;
  13.         printf("%d ", **p);
  14.     }
retagged by

Please log in or register to answer this question.

Related questions

0 votes
0 votes
1 answer
2
Chhotu asked Nov 20, 2017
532 views
Hi,Why multiple dereferencing is not creating problem in the following program ?https://ideone.com/3Li06v (Check line 1,2 & 3. all are giving same O/P)
1 votes
1 votes
0 answers
3
Ashish Roy 1 asked Mar 16, 2019
1,684 views
In the above 4 Statements which would print 123 as output ? Explain also.
0 votes
0 votes
1 answer
4
Psnjit asked Jan 12, 2019
1,157 views
main(){unsigned int i= 255;char *p= &i;int j= *p;printf("%d\n", j);unsigned int k= *p;printf("%d", k);} Both the outputs are -1. I have even tried with - int i = 255(3rd ...