int *i; //定义一个整型数字的指针变量 i
int p = 34;
i = &p;
printf("i value = %d ,address = %p",*i,i);
return0;
i value = 34 ,address = 0x7fff5fbff854
#include <stdio.h>
#include <ctype.h> // 包括字符处理函数
void swap(int *i,int *p);
int main(int argc, const char * argv[])
{
int i = 5;
int p = 10;
printf("i = %d, p = %d\n",i,p);
swap(&i, &p);
printf("i = %d, p = %d",i,p);
return 0;
}
void swap(int *i, int *p)
{
int temp = *i;
*i = *p;
*p = temp;
}
i = 5, p = 10
i = 10, p = 5