title: How to change the address of a pointer of a parameter in a function?
body: <p>I created a function to change the value of <code>*a</code>, but it remains unchanged after the function <code>fun</code> has been executed.</p>
  <p>Here's my code.</p>
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  void fun(int *b){
      int *c = new int;
      *c = 4;
      b = c;
  }
  int main(){
      int *a = new int;
      *a = 2;
      fun(a);
      cout &lt;&lt; *a &lt;&lt; endl; // the output is 2 but I want it be 4
      return 0;
  }
  </code></pre>
  <p>I want <code>*a</code> be <code>4</code> in function <code>fun</code></p>