title: Check whether a pointer points to a empty space on a int array
body: <p>So, I've got a assignment that asks for me to compare 2 arrays of integers (a[5] and b[8]) and check for repeated elements using pointers.
  So far, here's the code I came up with:</p>
  
  <pre><code>int main(void) {
      int *pa, i, j, sizeA=5, sizeB=8, a[sizeA], b[sizeB], aux[sizeB];
      for (i=0; i&lt;sizeA; i++){
          scanf("%d", &amp;a[i]);
      }
      for (i=0; i&lt;sizeB; i++){
          scanf("%d", &amp;b[i]);
      }
      for (i=0; i&lt;sizeB; i++){
          aux[i] = NULL;
      }
      for(i=0;i&lt;sizeA; i++){
          for(j=0; j&lt;sizeB; j++){
              if ((a[i] == b[j]))
                  aux[i] = b[j];
          }
      }
      for(i=0;i&lt;sizeA; i++){
          pa = &amp;aux[i];
          if ((pa != NULL)&amp;&amp;(*pa!=aux[i+1])){
              printf("%d \n", *pa);
          }
      }
  
  
      return (EXIT_SUCCESS);
  }
  </code></pre>
  
  <p>It got compiled and run without errors, but when there are no repeated elements, the last for Loop prints strange values such as 435304.</p>
  
  <p>I tried to make the pointer "pa" scan through the array "aux", and only print elements that are different from the next one on the array, and check if the position the pointer is pointing is empty.</p>
  
  <p>Any tips?</p>
  
  <p>EDIT: I solved it initializing the aux array with NULL values. Does it count as a valid solution? Is there a better way to do it?</p>
  
  <p>EDIT2: Thanks to everybody that helped me. Have a nice day.</p>