title: using void pointer in swap function
body: <p>I have a swap function like so:</p>
  
  <pre><code>void swap(int i, int j, void* arr[])
  {
      void *temp;
      temp = arr[i];
      arr[i] = arr[j];
      arr[j] = temp;
  }
  </code></pre>
  
  <p>I call swap in main like so:</p>
  
  <pre><code>main()
  {
      int arr[8] = {4,7,9,2,6,7,8,1};
      void *ptr = arr;
      swap(0, 1, ptr);
      int k;
      for (k=0; k&lt;8; k++)
          printf("%d ", arr[k]);
  }
  </code></pre>
  
  <p>Now, the swap seems to work fine, however instead of swapping 1 value with another, it is swapping 2 values with another 2 values. For example, when I do swap(0, 1, ptr), i get the array </p>
  
  <pre><code>9,2,4,7,6,7,8,1
  </code></pre>
  
  <p>when I should be getting:</p>
  
  <pre><code>7,4,9,2,6,7,8,1
  </code></pre>
  
  <p>Instead of swapping 4 and 7, it is swapping 4,7 with 9,2. Why is it doing this?</p>