标签:指针
#include <stdio.h> #include <stdlib.h> void main() { int arr[] = {1,3,5}; //一般数组赋值 int arr1[3]; for (int i =0; i < 3; i++) { arr1[i] = arr[i];//这个没什么好说的了 printf("arr1[i] =%d\n", arr1[i]); } //指针数组赋值 int *arr2[3];//指针数组,说明了,指针指向一个数组,和arr类型匹配了 for (int i =0; i < 3; i++) { arr2[i] = &arr[i]; printf("arr2[i] =%d", *(arr2[i])); printf("*(arr2 + i) = %d\n", **(arr2 + i)); } const int *p; int const *p1; int (*p3)[3];//数组指针 p3 = &arr;//数组整体大小空间 for (int i =0; i<3; i++) { printf("------p3 =%d\n", **(p3++));//越界 } //printf("&arr =%d------", &arr); //printf("arr =%d\n", arr); p = arr; for (int i =0; i<3; i++) { printf("%d\n",*p++); } //int *const p2;//指针本身值不能改变,未初始化报错 int *const p2 = arr; //printf("%d\n",*p2); /*for (int i=0; i < 3; i++) { printf("%d\n",*p2++);//p2 不可改变,所以懂了撒 }*/ system("pause");
标签:指针
原文地址:http://blog.csdn.net/u010236550/article/details/46535539