c指针(1)

#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
",c,d);
    dummy_swap(&c,&d);
    printf("c=%d,d=%d
",c,d);
    swap(&c,&d);
    printf("c=%d,d=%d
",c,d);
    printf("-----------------分割线-----------------
");
    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;
}

原文地址:https://www.cnblogs.com/qiangua/p/3482787.html