1. Engineering
  2. Computer Science
  3. c program in fooint q below it changes the global...

Question: c program in fooint q below it changes the global...

Question details

c program

In foo(int q) below, it changes the global int pointer (int *p) to the address of parameter (&q). After a call to bar(int c), what do you see?

#include <stdio.h>

int *p;

void foo(int q)

{

p = &q;

}

void bar(int c) {}

int main()

{

foo(11);

bar(12);

printf("%d\n", *p);

return 0;

}

Explain the output.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution