I have the following code which I want to make it so that board now has the value of new_board and vice versa. Since they are both pointers I thought I could just swap the addresses they point to. When I print in print2() the addresses are appropriately swapped. However, when I print in print1() the addresses have somehow swapped back, which doesn't make any sense to me. Further if I print out the values in the board at print2() they are also correct.
main(){
char *new_board = (char *)malloc(sizeof(char) * rows * cols );
char *board = (char *)malloc(sizeof(char) * rows * cols );
update_board2(board, new_board, rows, cols);
print1();
}
void update_board2(char *board, char *new_board, int rows, int cols){
//do a bunch of stuff
char *temp = board;
board = new_board;
new_board = temp;
print2();
}