当我这样修改交换函数时会发生什么?

问题描述 投票:0回答:1

当我们以这种方式修改交换函数时会发生什么?我知道这行不通,但到底是怎么回事?我不了解我实际上做了什么?

#include <stdio.h>

void swap(int*, int*);
int main(){
   int x=5,y=10;
   swap(&x, &y);
   printf("x:%d,y:%d\n",x,y);
   return 0;
 }

  void swap(int *x, int *y){ 
     int* temp;
     temp=x;
     x=y;
     y=temp;
    }
c++ c pointers memory swap
1个回答
1
投票

在功能中

© www.soinside.com 2019 - 2024. All rights reserved.