title: Calculate the sum of two numbers and "return" it by using a void function in C with a pointer as parameter
body: <p>So basically I'd like to sum two numbers and return their value while using a void function in C. I know this is easy peasy by using a normal function returning an int or a numeric type but I wanna work on my pointer knowledge.</p>
  <p>I tried creating a pointer inside main() and then passing it as an argument to the void function. Then I calculated my sum in a new int variable and assigned the pointer to point to that specific variable. The problem is I can't &quot;retrieve&quot; it or &quot;find&quot; that area of memory in the main function.</p>
  <p>Here's what I've tried:</p>
  <pre><code>void testFunction(int a,int b, int *x)
  {
     int c=a+b;
     x=&amp;c; 
  }
  
  int main()
  {
    int n1=7;
    int n2=90;
    int *pointerParam;
    testFunction(n1, n2, pointerParam);
     
    printf(&quot;Value of pointer is %d\n&quot;, *pointerParam);
  }
  </code></pre>
  <p>It just exits with an error code, it does nothing. If I try to printf *x inside the function, it does work so I know that part at least works.</p>
  <p>Any help would be greatly appreciated!</p>