You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test.cpp 2.9 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. 纯记录指针及其相关内容
  3. ███████╗██████╗ ██████╗ ███████╗ ███████╗███╗ ██╗ ██████╗ ██╗███╗ ██╗███████╗
  4. ██╔════╝██╔══██╗██╔════╝ ██╔════╝ ██╔════╝████╗ ██║██╔════╝ ██║████╗ ██║██╔════╝
  5. █████╗ ██║ ██║██║ ███╗█████╗ █████╗ ██╔██╗ ██║██║ ███╗██║██╔██╗ ██║█████╗
  6. ██╔══╝ ██║ ██║██║ ██║██╔══╝ ██╔══╝ ██║╚██╗██║██║ ██║██║██║╚██╗██║██╔══╝
  7. ███████╗██████╔╝╚██████╔╝███████╗ ███████╗██║ ╚████║╚██████╔╝██║██║ ╚████║███████╗
  8. ╚══════╝╚═════╝ ╚═════╝ ╚══════╝ ╚══════╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝╚═╝ ╚═══╝╚══════╝
  9. Author:Edge
  10. Web:likedge.top
  11. Date:20201213
  12. Data_struct_define
  13. link_list: ll
  14. graph
  15. ---------------------------------------------------------------
  16. if you have the better answer on it , it is nothing, just test~
  17. ---------------------------------------------------------------
  18. */
  19. #include<iostream>
  20. using namespace std;
  21. int main(){
  22. cout<<"hello,world"<<endl;
  23. //---------------------------------------------------------
  24. int a=5;
  25. int *p1=&a;//p1指针变量,变量类型是int *
  26. cout<<p1<<endl;
  27. int **p2=&p1;//p2指针变量,变量类型int **,指向a的地址的地址
  28. cout<<p2<<endl;
  29. int array[5];
  30. //指针遍历数组,ptr运算向前
  31. //--------------------------------------------------------
  32. int *ptr=array;
  33. array[0]=1;
  34. array[1]=2;
  35. array[2]=222;
  36. array[3]=333;
  37. array[4]=0;
  38. int p=array[1];//第一种访问方式
  39. cout<<p<<endl;
  40. int pp=*(array+1);//第二种访问数组第二个元素的方式
  41. cout<<pp<<endl;
  42. for(int i=0;i<5;i++)
  43. {
  44. cout<<*ptr<<endl;
  45. ptr++;
  46. cout<<ptr<<endl;
  47. // 0x7ffee2cb7310
  48. // 1
  49. // 0x7ffee2cb7324
  50. // 2
  51. // 0x7ffee2cb7328
  52. // 222
  53. // 0x7ffee2cb732c
  54. // 333
  55. // 0x7ffee2cb7330
  56. // 0
  57. // 0x7ffee2cb7334
  58. // 每次增长4位,int类型4个字节
  59. }
  60. //-----------------------------------------------------
  61. return 0;
  62. }

Edge : 一个开源的科学计算引擎

Contributors (1)