Swapping pointer to pointer
<p>In this program I'm writing, I'm using 2 matrices declared as pointer to pointer. Initially, matrix B is equal to matrix A, and all the changes are being made to matrix B (I need to not modify the values in A because I'm using those values to compute something else and if I directly modify it I practically get the wrong result). In the end, I need to swap the values in the two matrices. My program is already running and compiling, but to swap the matrices I've used </p>

<pre><code>for(i=0;i&lt;n;++i)
    for(j=0;j&lt;n;++j)
        A[i][j]=B[i][j];
</code></pre>

<p>I know that's not the best method, so I was wondering whether there's a way to swap my matrices by pointers. I've already tried to do it myself. but I'm new to C++ programming and I cannot seem to manage to do it right :(. </p>

<p>This is a sketch of my code: </p>

<pre><code>void swap(int **A, int **B){
?
}

main (){
int **A, **B;
*code*
swap(A,B);
}
</code></pre>
