慕课网程序设计入门——C语言( 翁恺老师)学习笔记2、指针

1、运算符&:取得变量地址,变量存放在内存里

     取地址:printf("%p",&i);

2、指针类型的变量:保存地址

        int * p = &i;

           int型变量 i 

           *表示p是一个指针,指向了int型变量i的地址

          *p作为一个整体,是一个整数

3、运算符*:访问指针

4、数组与指针:int sum(int *ar,int n);等价于int sum(int ar[],int n);

     对数组取地址,无需&

     对数组单元取地址,需&

     数组是常量指针

     函数参数里的数组是指针(int型

     数组变量是const指针

5、常见错误

     定义可指针变量,没有让它指向某一变量,不能用

6、mallco

     #include<stdlib.h>

     返回 void* malloc(sizeof(int))

     free();

猜你喜欢

转载自blog.csdn.net/m7kise/article/details/80149764