qiangua
#include<stdio.h>

void swap(int *a,int *b);
void dummy_swap(int *a,int *b);
int main()
{
    int c=3,d=76;
    swap(&c,&d);
    printf("c=%d,d=%d\n",c,d);
    dummy_swap(&c,&d);
    printf("c=%d,d=%d\n",c,d);
    swap(&c,&d);
    printf("c=%d,d=%d\n",c,d);
    printf("-----------------分割线-----------------\n");
    return 0;
}
void swap(int *a,int *b)
{
    int temp=0;
    //更改指针指向的值
    temp=*a;
    *a=*b;
    *b=temp;
}
//不要妄图使用下面的做法
void dummy_swap(int *a,int *b)
{
    int *temp=NULL;
    //更改指针值
    temp=a;
    a=b;
    b=temp;
}

分类:

技术点:

相关文章:

  • 2021-11-18
  • 2021-10-21
  • 2021-11-18
  • 2021-11-18
  • 2021-10-17
  • 2021-05-18
  • 2021-06-27
  • 2018-06-24
猜你喜欢
  • 2021-11-18
  • 2021-11-18
  • 2021-11-18
  • 2021-11-18
  • 2021-11-18
  • 2021-08-14
  • 2021-11-25
相关资源
相似解决方案