# 性质
# 宽度
固定为 4 字节
# 声明
| int* a; int *a; |
| 数据类型* a; 数据类型 *a; |
| 两者相同 |
# 赋值
| void test() |
| { |
| int a; |
| a=10; |
| } |
| |
| 对比 |
| |
| void test2() |
| { |
| int* a; |
| char***** b; |
| |
| a=(int*)10; |
| b=(char*****)20; |
| } |
# 运算
# ++--
++ 或 --,变化的数值取决于去掉一个 * 号后的数据的宽度
| void test() |
| { |
| char* a; |
| short* b; |
| int* c; |
| |
| char** a1; |
| short* b1; |
| int* c1; |
| |
| |
| a=(char*)10; |
| b=(short*)10; |
| c=(int*)10; |
| |
| a1=(char*)10; |
| b1=(short*)10; |
| c1=(int*)10; |
| |
| |
| a++; |
| b++; |
| c++; |
| a1++; |
| b1++; |
| c1++; |
| |
| printf("%d %d %d %d %d %d %d",a,b,c,a1,b1,c1) |
| |
| } |
# 加减法
加(减)X 就相当于 ++(--)X 次
| void test() |
| { |
| char* a; |
| short* b; |
| int* c; |
| |
| a=(char*)10; |
| b=(short*)10; |
| c=(int*)10; |
| |
| a=a+5; |
| b=b+5; |
| c=c+5; |
| |
| printf("%d %d %d",a,b,c) |
| } |
# 相减
| void test() |
| { |
| short* a; |
| short* b; |
| |
| a=(short*)200; |
| b=(short*)100; |
| |
| int x=a-b; |
| |
| printf("%d",x) |
| } |
| |
| void test1() |
| { |
| short** a; |
| short** b; |
| |
| a=(short**)200; |
| b=(short**)100; |
| |
| int x=a-b; |
| |
| printf("%d",x) |
| } |
# 比较大小
| void test() |
| { |
| short* a; |
| short* b; |
| |
| a=(short*)200; |
| b=(short*)100; |
| |
| if(a>b) |
| { |
| printf("1"); |
| } |
| if(b>a) |
| { |
| printf("0"); |
| } |
| } |
# 应用
# 类型转换
| void test() |
| { |
| char* a; |
| int* b; |
| |
| a=(char*)10; |
| b=(int*)a; |
| |
| } |
# 符号的使用
# 求值
# 指针操作数组