|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- /*
- 纯记录指针及其相关内容
- ███████╗██████╗ ██████╗ ███████╗ ███████╗███╗ ██╗ ██████╗ ██╗███╗ ██╗███████╗
- ██╔════╝██╔══██╗██╔════╝ ██╔════╝ ██╔════╝████╗ ██║██╔════╝ ██║████╗ ██║██╔════╝
- █████╗ ██║ ██║██║ ███╗█████╗ █████╗ ██╔██╗ ██║██║ ███╗██║██╔██╗ ██║█████╗
- ██╔══╝ ██║ ██║██║ ██║██╔══╝ ██╔══╝ ██║╚██╗██║██║ ██║██║██║╚██╗██║██╔══╝
- ███████╗██████╔╝╚██████╔╝███████╗ ███████╗██║ ╚████║╚██████╔╝██║██║ ╚████║███████╗
- ╚══════╝╚═════╝ ╚═════╝ ╚══════╝ ╚══════╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝╚═╝ ╚═══╝╚══════╝
- Author:Edge
- Web:likedge.top
- Date:20201213
-
- Data_struct_define
- link_list: ll
- graph
-
-
- ---------------------------------------------------------------
- if you have the better answer on it , it is nothing, just test~
- ---------------------------------------------------------------
-
- */
- #include<iostream>
- using namespace std;
- int main(){
- cout<<"hello,world"<<endl;
- //---------------------------------------------------------
- int a=5;
- int *p1=&a;//p1指针变量,变量类型是int *
- cout<<p1<<endl;
- int **p2=&p1;//p2指针变量,变量类型int **,指向a的地址的地址
- cout<<p2<<endl;
- int array[5];
- //指针遍历数组,ptr运算向前
- //--------------------------------------------------------
- int *ptr=array;
- array[0]=1;
- array[1]=2;
- array[2]=222;
- array[3]=333;
- array[4]=0;
- int p=array[1];//第一种访问方式
- cout<<p<<endl;
- int pp=*(array+1);//第二种访问数组第二个元素的方式
- cout<<pp<<endl;
- for(int i=0;i<5;i++)
- {
- cout<<*ptr<<endl;
- ptr++;
- cout<<ptr<<endl;
- // 0x7ffee2cb7310
- // 1
- // 0x7ffee2cb7324
- // 2
- // 0x7ffee2cb7328
- // 222
- // 0x7ffee2cb732c
- // 333
- // 0x7ffee2cb7330
- // 0
- // 0x7ffee2cb7334
- // 每次增长4位,int类型4个字节
- }
- //-----------------------------------------------------
-
- return 0;
- }
|