#include<stdio.h> void Stmp_Num(int * a, int * b) //利用整型指针接收整型变量的地址 { int stmp = *a; //将两变量值交换 *a = *b; *b = stmp; } int main() { int a = 1; int b = 2; scanf("a=%d,b=%d", &a, &b); Stmp_Num(&a, &b); //传址的调用 printf("a=%d,b=%d", a, b); return 0; }
#include<stdio.h> void Stmp_Num(int * a, int * b) //利用整型指针接收整型变量的地址 { int stmp = *a; //将两变量值交换 *a = *b; *b = stmp; } int main() { int a = 1; int b = 2; scanf("a=%d,b=%d", &a, &b); Stmp_Num(&a, &b); //传址的调用 printf("a=%d,b=%d", a, b); return 0; }