title: Exercise: Using pointers cross-function in C Language returns error "invalid type argument of unary ‘*’ (have ‘int’)"
body: <p>I'm new here so sorry if this post is not properly edited. </p>
  
  <p>I'm currently trying to resolve some exercises using C, to put in practice some stuff I've been studying recently, but I keep getting several distinct errors when using pointers, which I'm not being able to figure out by myself.</p>
  
  <p>In this case I have this challenge from Hackerrank, and I was supposed to return the sum of all the array's elements, but I keep getting this compilation error in line 12: <code>invalid type argument of unary ‘*’ (have ‘int’)</code></p>
  
  <pre><code>#include &lt;math.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;assert.h&gt;
  #include &lt;limits.h&gt;
  #include &lt;stdbool.h&gt;
  
  int simpleArraySum(int ar_size, int* ar) {
      int sum = 0;
      for (int i = 0; i &lt; ar_size; i++){
          sum += *ar[i];                     //line 12
      }
      return sum;
  }
  
  int main() {
      int n; 
      scanf("%i", &amp;n);
      int *ar = malloc(sizeof(int) * n);
      for(int ar_i = 0; ar_i &lt; n; ar_i++){
         scanf("%i",&amp;ar[ar_i]);
      }
      int result = simpleArraySum(n, ar);
      printf("%d\n", result);
      return 0;
  }
  </code></pre>
  
  <p>I know it involves the use of pointers, but I'm not sure how to handle it. I've tried using <code>int *sum = malloc(sizeof(int));</code> and <code>*sum += *ar[i];</code> but the same error persists.</p>
  
  <p>Any advices?</p>