c语言之指针与数组
2015-08-29 09:49
369 查看
多级指针:
数组指针
指针数组
int main() { int i=10; int *p=&i; int **pp=&p; int ***ppp=&pp; cout<<p<<":"<<*p<<":"<<endl; cout<<pp <<":"<<*pp<<":"<<**pp<<":"<<endl; cout<<ppp<<":"<<*ppp<<":"<<**ppp <<":" <<***ppp<<":" <<endl; return 0; }
数组指针
void main() { int a[3][3]={ 1,2,3,4,5,6,7,8,9}; int (*q)[3];//数组指针 q=a; cout<<q<<endl;//0012ff24 cout<<*q<<endl;//0012ff24 cout<<*q+1<<endl;//0012ff28//p+4bit cout<< *q[0]<<endl;//1 cout<< **q <<endl;//1 等同上 cout<<**q+100<<endl;//101 cout<<**(q+1)<<endl;//4 cout<<*(*q+1)<<endl;//2 cout<<q+1<<endl;//0012ff30 cout<<*(q+1)<<endl;//0012ff30 cout<<q+3<<endl;//0012ff48, cout<<*q+1<<endl; }
指针数组
void main() { int a[3][3]={ 1,2,3,4,5,6,7,8,9}; int *q[3];//指针数组 for(int i=0;i<3;i++) q[i]=a[i]; cout<<q<<endl;//ff18 q本身 cout<<*q<<endl;//ff24 a[0][0]地址 cout<<*q+1<<endl;//ff28 a[0][1] cout<<*(q+1)<<endl;//ff30 a[1][0] cout<<**q<<endl;//1 a[0][0]的值 cout<<*(*q+1)<<endl;//2 a[0][1]的值 cout<<**(q+1)<<endl;//4 a[1][0]的值 }
#include<stdio.h> #include<iostream> using namespace std; char *c[]={"ENTER","NEW","POINT","FIRST"}; char **cp[]={c+3,c+2,c+1,c}; char ***cpp=cp; int main(void) { printf("%s ",**++cpp);//POINT ++cpp printf("%s ",*--*++cpp+3);// ER printf("%s ",*cpp[-2]+3);//ST printf("%s\n",cpp[-1][-1]+1);//EW return 0; }
相关文章推荐
- C++派生类的构造函数和析构函数执行顺序及其构造形式
- memcpy 函数详解
- C++中随机函数rand()和srand()的用法
- 双循环链表(C++)
- 单链表(c++带头结点,)
- C语言对组文件处理的相关函数小结
- 《IOS_C语言》一维数组、数组排序、字符数组
- doxygen的使用与C/C++注释规范
- 基于Doxygen的C/C++注释原则
- 一起talk C栗子吧(第四十三回:C语言实例--图)
- C语言类型占多少字节
- C语言的字符处理函数库
- c语言-一些学习c的经典例子
- 条款5:了解C++默默编写并调用哪些函数(Know what functions C++ silently writes and calls)
- c语言-指针实现链表增删改查
- C++编程常用头文件及其包含函数汇总
- C/C++常用头文件及函数汇总
- [C语言][LeetCode][48]Rotate Image
- 如何成为一个牛逼的C/C++程序员?
- C/C++程序员必须熟练应用的开源项目