How to swap 2 integers using pointers?
<p>when I try to swap these two integers using pointers, I get segmentation fault. </p>

<p>Basically before I swap, <code>x</code> is assigned to <code>1</code> and <code>y</code> is assigned to <code>2</code>. After I swap <code>x</code> is assigned to <code>2</code> and <code>y</code> is assigned to <code>1</code>. </p>

<p>The program takes two integers <code>x</code> and <code>y</code> and is supposedly meant to swap them:</p>

<pre><code>int swap(int x, int y){

    int *swapXtoY;
    int *swapYtoX;

    *swapXtoY = y;
    *swapYtoX = x;
}
</code></pre>