C算法--指针1

mac2022-06-30  21

1 #include <stdio.h> 2 3 /*在变量前面加上&就可以表示变量的地址*/ 4 int main(){ 5 int a=1; 6 printf("%d,%d\n",&a,a); 7 return 0; 8 } 在变量前面加上&就可以表示变量的地址

指针变量

int* p;

double* p;

char* p;

int* p1,p2;    //p1是int*型的,p2是int 型的。

-------------------

int a;

int *p=&a;

int a;

int *p;

p=&a;

---------------

int a,b;

int *p1=&a,*p2=&b;

--------------------------

1 #include <stdio.h> 2 3 int main() { 4 int a; 5 int *p=&a; 6 a=233; 7 printf("%d\n",p);//p是地址 8 printf("%d\n",*p);//*p是a存入的值 9 return 0; 10 } P是地址*p是地址中的元素

 

转载于:https://www.cnblogs.com/Catherinezhilin/p/11136285.html

最新回复(0)