Is it possible to swap the addresses of two variables?

前端 未结 3 1625
遥遥无期
遥遥无期 2021-01-15 16:10

I know that it is possible to swap the value of two variables like so

#include 

void swap(int *x, int *y);
int main(){
    int x=5,y=10;
             


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-15 16:55

    No, that's not possible. You don't get to choose the addresses of variables and you can't modify them either.

提交回复
热议问题