title: C pointers and arrays: [Warning] assignment makes pointer from integer without a cast
body: <p>I'm having some trouble with pointers and arrays in C. Here's the code:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  
  int *ap;
  int a[5]={41,42,43,44,45};
  int x;
  
  int main()
  {
      ap = a[4];
      x = *ap;
      printf("%d",x);
      return 0;
  }
  </code></pre>
  
  <p>When I compile and run the code I get this warning:</p>
  
  <blockquote>
    <p>[Warning] assignment makes pointer from integer without a cast
    [enabled by default]</p>
  </blockquote>
  
  <p>For line number 9 (ap = a[4];) and the terminal crashes. If I change line 9 to not include a position (ap = a;) I don't get any warnings and it works. Why is this happening? I feel like the answer is obvious but I just can't see it.</p>