通過指針變量通路整型變量。
程式:
#include<stdio.h>
int main()
{
int *p1, *p2, *p, a, b;
printf("please enter two integer numbers:");
scanf("%d,%d", &a, &b);
p1 = &a;
p2 = &b;
if (a < b)
p = p1;
p1 = p2;
p2 = p;
/*p1=&b;
p2=&a;*/
}
printf("a=%d,b=%d\n", a, b);
printf("max=%d,min=%d\n", *p1, *p2);
return 0;
結果:
a=2,b=3
*p1=2,*p2=3
請按任意鍵繼續. . .